@dynamic-labs-sdk/aptos 1.17.1 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/addAptosExtension/addAptosExtension.d.ts +10 -1
  2. package/dist/addAptosExtension/addAptosExtension.d.ts.map +1 -1
  3. package/dist/{addAptosWalletStandardExtension-BeX9GJpF.cjs → addAptosWalletStandardExtension-CJmRqCMM.cjs} +33 -4
  4. package/dist/addAptosWalletStandardExtension-CJmRqCMM.cjs.map +1 -0
  5. package/dist/{addAptosWalletStandardExtension-jiIkABI0.esm.js → addAptosWalletStandardExtension-Drme8SEO.esm.js} +33 -4
  6. package/dist/addAptosWalletStandardExtension-Drme8SEO.esm.js.map +1 -0
  7. package/dist/getAptosClient/getAptosClient.d.ts +10 -4
  8. package/dist/getAptosClient/getAptosClient.d.ts.map +1 -1
  9. package/dist/index.cjs +67 -16
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.esm.js +67 -16
  12. package/dist/index.esm.js.map +1 -1
  13. package/dist/isAptosNetworkProvider/isAptosNetworkProvider.d.ts +16 -1
  14. package/dist/isAptosNetworkProvider/isAptosNetworkProvider.d.ts.map +1 -1
  15. package/dist/isAptosWalletAccount/isAptosWalletAccount.d.ts +15 -1
  16. package/dist/isAptosWalletAccount/isAptosWalletAccount.d.ts.map +1 -1
  17. package/dist/isAptosWalletProvider/isAptosWalletProvider.d.ts +16 -1
  18. package/dist/isAptosWalletProvider/isAptosWalletProvider.d.ts.map +1 -1
  19. package/dist/signAndSubmitTransaction/signAndSubmitTransaction.d.ts +16 -6
  20. package/dist/signAndSubmitTransaction/signAndSubmitTransaction.d.ts.map +1 -1
  21. package/dist/signTransaction/signTransaction.d.ts +18 -7
  22. package/dist/signTransaction/signTransaction.d.ts.map +1 -1
  23. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  24. package/dist/walletStandard.cjs +1 -1
  25. package/dist/walletStandard.esm.js +1 -1
  26. package/package.json +4 -4
  27. package/dist/addAptosWalletStandardExtension-BeX9GJpF.cjs.map +0 -1
  28. package/dist/addAptosWalletStandardExtension-jiIkABI0.esm.js.map +0 -1
@@ -4,8 +4,17 @@
4
4
  * This is a convenience function that adds support for all of Aptos wallets that support the Aptos Wallet Standard,
5
5
  * like Petra, Backpack, OKX, Nightly, and more.
6
6
  *
7
+ * @example
8
+ * ```ts
9
+ * const client = createDynamicClient({ environmentId: 'env-123' });
10
+ * addAptosExtension(client);
11
+ * ```
12
+ *
7
13
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
8
- * @notInstrumented
14
+ * @returns void
15
+ * @see isAptosWalletAccount
16
+ * @see isAptosNetworkProvider
17
+ * @notInstrumented
9
18
  */
10
19
  export declare const addAptosExtension: (client?: import("@dynamic-labs-sdk/client").DynamicClient) => void;
11
20
  //# sourceMappingURL=addAptosExtension.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"addAptosExtension.d.ts","sourceRoot":"","sources":["../../src/addAptosExtension/addAptosExtension.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,iEAAkC,IAE/D,CAAC"}
1
+ {"version":3,"file":"addAptosExtension.d.ts","sourceRoot":"","sources":["../../src/addAptosExtension/addAptosExtension.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,iEAAkC,IAE/D,CAAC"}
@@ -6,7 +6,7 @@ let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
6
6
 
7
7
  //#region package.json
8
8
  var name = "@dynamic-labs-sdk/aptos";
9
- var version = "1.17.1";
9
+ var version = "1.19.0";
10
10
 
11
11
  //#endregion
12
12
  //#region src/utils/constants.ts
@@ -68,12 +68,41 @@ var NotAptosProviderError = class extends _dynamic_labs_sdk_client.BaseError {
68
68
 
69
69
  //#endregion
70
70
  //#region src/isAptosWalletAccount/isAptosWalletAccount.ts
71
- /** @notInstrumented */
71
+ /**
72
+ * Type guard function to check if a wallet account is an Aptos wallet account.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const accounts = getWalletAccounts();
77
+ * const aptosAccounts = accounts.filter(isAptosWalletAccount);
78
+ * ```
79
+ *
80
+ * @param walletAccount - The wallet account to check.
81
+ * @returns True if the wallet account is an Aptos wallet account, false otherwise.
82
+ * @see isAptosNetworkProvider
83
+ * @see addAptosExtension
84
+ * @notInstrumented
85
+ */
72
86
  const isAptosWalletAccount = (walletAccount) => walletAccount.chain === "APTOS";
73
87
 
74
88
  //#endregion
75
89
  //#region src/isAptosWalletProvider/isAptosWalletProvider.ts
76
- /** @notInstrumented */
90
+ /**
91
+ * Type guard function to check if a wallet provider is an Aptos wallet provider.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * if (isAptosWalletProvider(provider)) {
96
+ * const aptosClient = await provider.getAptosClient();
97
+ * }
98
+ * ```
99
+ *
100
+ * @param provider - The wallet provider to check.
101
+ * @returns True if the wallet provider is an Aptos wallet provider, false otherwise.
102
+ * @see isAptosWalletAccount
103
+ * @see addAptosExtension
104
+ * @notInstrumented
105
+ */
77
106
  const isAptosWalletProvider = (provider) => {
78
107
  return provider.chain === "APTOS";
79
108
  };
@@ -362,4 +391,4 @@ Object.defineProperty(exports, 'version', {
362
391
  return version;
363
392
  }
364
393
  });
365
- //# sourceMappingURL=addAptosWalletStandardExtension-BeX9GJpF.cjs.map
394
+ //# sourceMappingURL=addAptosWalletStandardExtension-CJmRqCMM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addAptosWalletStandardExtension-CJmRqCMM.cjs","names":["Aptos","AptosConfig","BaseError","InvalidParamError","transaction: AptosTransactionPayload","features: AptosFeatures","WalletProviderEnum","connect: AptosWalletProvider['connect']","UserResponseStatus","UserRejectedError","getActiveNetworkId: AptosWalletProvider['getActiveNetworkId']","getAptosClient: AptosWalletProvider['getAptosClient']","Aptos","AptosConfig","getConnectedAddresses: AptosWalletProvider['getConnectedAddresses']","signTransaction: AptosWalletProvider['signTransaction']","signAndSubmitTransaction: AptosWalletProvider['signAndSubmitTransaction']","signMessage: AptosWalletProvider['signMessage']","publicKey: string | undefined","destroy: AptosWalletProvider['destroy']","REQUIRED_FEATURES: (keyof MinimallyRequiredFeatures)[]","WalletProviderPriority"],"sources":["../package.json","../src/utils/constants.ts","../src/utils/fetchAptosBalance/fetchAptosBalance.ts","../src/utils/createAptosNetworkProvider/createAptosNetworkProvider.ts","../src/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.ts","../src/errors/NotAptosProviderError/NotAptosProviderError.ts","../src/isAptosWalletAccount/isAptosWalletAccount.ts","../src/isAptosWalletProvider/isAptosWalletProvider.ts","../src/utils/aptosTransferAmount/aptosTransferAmount.ts","../src/walletStandard/utils/createWalletProviderFromAptosStandardWallet/createWalletProviderFromAptosStandardWallet.ts","../src/walletStandard/utils/hasAllRequiredFeatures/hasAllRequiredFeatures.ts","../src/walletStandard/utils/registerAptosStandardWallet/registerAptosStandardWallet.ts","../src/walletStandard/addAptosWalletStandardExtension/addAptosWalletStandardExtension.ts"],"sourcesContent":["","// 1 APT = 10^8 octas (similar to 1 BTC = 10^8 satoshis)\nexport const OCTAS_PER_APT = 1e8;\n","import type { Network } from '@aptos-labs/ts-sdk';\nimport { Aptos, AptosConfig } from '@aptos-labs/ts-sdk';\nimport type { NetworkData } from '@dynamic-labs-sdk/client';\n\nimport { OCTAS_PER_APT } from '../constants';\n\ntype FetchAptosBalanceParams = {\n address: string;\n networkData: NetworkData;\n};\n\n/** @notInstrumented */\nexport const fetchAptosBalance = async ({\n address,\n networkData,\n}: FetchAptosBalanceParams): Promise<string | null> => {\n const config = new AptosConfig({\n fullnode: networkData.rpcUrls.http[0],\n network: networkData.cluster as Network,\n });\n\n const aptosClient = new Aptos(config);\n\n const balance = await aptosClient.getBalance({\n accountAddress: address,\n // APT coin type\n asset: '0x1::aptos_coin::AptosCoin',\n });\n\n return (Number(balance) / OCTAS_PER_APT).toString();\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { createBaseNetworkProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosNetworkProvider } from '../../AptosNetworkProvider.types';\nimport { fetchAptosBalance } from '../fetchAptosBalance';\n\n/** @notInstrumented */\nexport const createAptosNetworkProvider = (\n networkData: NetworkData\n): AptosNetworkProvider => ({\n ...createBaseNetworkProvider('APTOS', networkData),\n cluster: networkData.cluster,\n getBalance: async ({ address }) => ({\n balance: await fetchAptosBalance({\n address,\n networkData,\n }),\n }),\n});\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getNetworkProviderBuilderRegistry } from '@dynamic-labs-sdk/client/core';\n\nimport { createAptosNetworkProvider } from '../utils/createAptosNetworkProvider';\n\n/** @notInstrumented */\nexport const registerAptosNetworkProviderBuilder = (\n client: DynamicClient\n): void => {\n const networkProviderBuilderRegistry =\n getNetworkProviderBuilderRegistry(client);\n\n // If the Aptos network provider builder is already registered, return.\n if (networkProviderBuilderRegistry.get().get('APTOS')) {\n return;\n }\n\n networkProviderBuilderRegistry.register({\n builder: createAptosNetworkProvider,\n chain: 'APTOS',\n });\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class NotAptosProviderError extends BaseError {\n public readonly providerKey: string;\n\n constructor(params: { providerKey: string }) {\n super({\n cause: null,\n code: 'not_aptos_provider_error',\n docsUrl: null,\n name: 'NotAptosProviderError',\n shortMessage: 'Provider is not an Aptos wallet provider',\n });\n\n this.providerKey = params.providerKey;\n }\n}\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { AptosWalletAccount } from '../AptosWalletAccount.types';\n\n/**\n * Type guard function to check if a wallet account is an Aptos wallet account.\n *\n * @example\n * ```ts\n * const accounts = getWalletAccounts();\n * const aptosAccounts = accounts.filter(isAptosWalletAccount);\n * ```\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is an Aptos wallet account, false otherwise.\n * @see isAptosNetworkProvider\n * @see addAptosExtension\n * @notInstrumented\n */\nexport const isAptosWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is AptosWalletAccount => walletAccount.chain === 'APTOS';\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosWalletProvider } from '../AptosWalletProvider.types';\n\n/**\n * Type guard function to check if a wallet provider is an Aptos wallet provider.\n *\n * @example\n * ```ts\n * if (isAptosWalletProvider(provider)) {\n * const aptosClient = await provider.getAptosClient();\n * }\n * ```\n *\n * @param provider - The wallet provider to check.\n * @returns True if the wallet provider is an Aptos wallet provider, false otherwise.\n * @see isAptosWalletAccount\n * @see addAptosExtension\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const isAptosWalletProvider = (\n provider: WalletProvider | AptosWalletProvider\n): provider is AptosWalletProvider => {\n return provider.chain === 'APTOS';\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { InvalidParamError } from '@dynamic-labs-sdk/client';\nimport {\n type TransferAmountParams,\n getWalletProviderFromWalletAccount,\n parseAmountToSmallestUnit,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosTransactionPayload } from '../../AptosWalletProvider.types';\nimport { NotAptosProviderError } from '../../errors/NotAptosProviderError';\nimport { isAptosWalletAccount } from '../../isAptosWalletAccount';\nimport { isAptosWalletProvider } from '../../isAptosWalletProvider';\n\nconst APT_DECIMALS = 8;\n\n/**\n * Transfers native APT or fungible tokens from one wallet to another.\n *\n * Converts the human-readable amount string to the smallest unit (octas for APT,\n * or the appropriate unit for fungible tokens) using string-based arithmetic\n * to avoid floating-point precision issues.\n * @notInstrumented\n */\nexport const aptosTransferAmount = async (\n { amount, recipient, token, walletAccount }: TransferAmountParams,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n if (!isAptosWalletAccount(walletAccount)) {\n throw new InvalidParamError(\n 'Wallet account is not an Aptos wallet account'\n );\n }\n\n const provider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (!isAptosWalletProvider(provider)) {\n throw new NotAptosProviderError({ providerKey: provider.key });\n }\n\n const decimals = token?.decimals ?? APT_DECIMALS;\n const smallestUnitAmount = parseAmountToSmallestUnit({ amount, decimals });\n\n let transaction: AptosTransactionPayload;\n if (token?.address) {\n transaction = {\n function: '0x1::primary_fungible_store::transfer',\n functionArguments: [token.address, recipient, Number(smallestUnitAmount)],\n typeArguments: ['0x1::fungible_asset::Metadata'],\n };\n } else {\n transaction = {\n function: '0x1::coin::transfer',\n functionArguments: [recipient, Number(smallestUnitAmount)],\n typeArguments: ['0x1::aptos_coin::AptosCoin'],\n };\n }\n\n const result = await provider.signAndSubmitTransaction({\n transaction,\n walletAccount,\n });\n\n return { transactionHash: result.hash };\n};\n","import type { Network } from '@aptos-labs/ts-sdk';\nimport { Aptos, AptosConfig } from '@aptos-labs/ts-sdk';\nimport type {\n AccountInfo,\n AptosFeatures,\n AptosWallet,\n} from '@aptos-labs/wallet-standard';\nimport { UserResponseStatus } from '@aptos-labs/wallet-standard';\nimport {\n type DynamicClient,\n UserRejectedError,\n assertWalletAccountSigningAvailability,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n createWalletProviderEventEmitter,\n formatWalletProviderGroupKey,\n formatWalletProviderKey,\n getActiveNetworkIdFromLastKnownRegistry,\n getCore,\n} from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { AptosWalletProvider } from '../../../AptosWalletProvider.types';\nimport { aptosTransferAmount } from '../../../utils/aptosTransferAmount';\n\ntype CreateWalletProviderFromAptosStandardWalletParams = {\n dynamicClient: DynamicClient;\n walletStandardWallet: AptosWallet;\n};\n\n/** @notInstrumented */\nexport const createWalletProviderFromAptosStandardWallet = ({\n dynamicClient,\n walletStandardWallet,\n}: CreateWalletProviderFromAptosStandardWalletParams): AptosWalletProvider => {\n const features: AptosFeatures = walletStandardWallet.features;\n\n const walletProviderType = WalletProviderEnum.BrowserExtension;\n\n const key = formatWalletProviderKey({\n chain: 'APTOS',\n displayName: walletStandardWallet.name,\n walletProviderType,\n });\n\n const getAutoConnectedAccount = ():\n | { address: string; publicKey: string }[]\n | undefined => {\n const accounts = walletStandardWallet.accounts;\n if (!accounts?.length || !accounts[0].publicKey || !accounts[0].address) {\n return;\n }\n\n return accounts.map((account) => ({\n address: account.address.toString(),\n publicKey: account.publicKey?.toString(),\n }));\n };\n\n const connect: AptosWalletProvider['connect'] = async () => {\n const autoConnectedAccounts = getAutoConnectedAccount();\n\n if (autoConnectedAccounts) {\n return {\n addresses: autoConnectedAccounts,\n };\n }\n\n const connectMethod = features['aptos:connect']?.connect;\n\n assertDefined(connectMethod, 'connect method not found in wallet features');\n\n const result = await connectMethod();\n\n if (result.status !== UserResponseStatus.APPROVED) {\n throw new UserRejectedError({ action: 'connect' });\n }\n\n return {\n addresses: [\n {\n address: result.args.address.toString(),\n publicKey: result.args.publicKey?.toString(),\n },\n ],\n };\n };\n\n const getActiveNetworkId: AptosWalletProvider['getActiveNetworkId'] =\n async () => {\n const aptosNetwork = await features['aptos:network']?.network();\n\n if (!aptosNetwork?.chainId) {\n return getActiveNetworkIdFromLastKnownRegistry({\n client: dynamicClient,\n walletProviderKey: key,\n });\n }\n\n return { networkId: aptosNetwork.chainId.toString() };\n };\n\n const getAptosClient: AptosWalletProvider['getAptosClient'] = async ({\n walletAccount,\n }) => {\n const activeNetworkData = await getActiveNetworkData(\n { walletAccount },\n dynamicClient\n );\n\n assertDefined(\n activeNetworkData.networkData,\n 'No active network data found'\n );\n\n const { rpcUrls, cluster } = activeNetworkData.networkData;\n\n const url = rpcUrls.http[0];\n\n assertDefined(url, 'No RPC URL found for active network');\n\n const network = cluster as Network;\n const config = new AptosConfig({ fullnode: url, network });\n\n return new Aptos(config);\n };\n\n const getConnectedAccount = async (): Promise<AccountInfo | undefined> => {\n const getAccountMethod = features['aptos:account']?.account;\n\n if (!getAccountMethod) {\n return undefined;\n }\n\n return getAccountMethod();\n };\n\n const getConnectedAddresses: AptosWalletProvider['getConnectedAddresses'] =\n async () => {\n const account = await getConnectedAccount();\n\n if (account) {\n return {\n addresses: [account.address.toString()],\n };\n }\n\n return {\n addresses: [],\n };\n };\n\n const signTransaction: AptosWalletProvider['signTransaction'] = async ({\n asFeePayer,\n transaction,\n walletAccount,\n }) => {\n await assertWalletAccountSigningAvailability(\n { walletAccount },\n dynamicClient\n );\n\n const signTransactionMethod =\n features['aptos:signTransaction']?.signTransaction;\n\n assertDefined(\n signTransactionMethod,\n 'signTransaction method not found in wallet features'\n );\n\n const result = await signTransactionMethod(transaction, asFeePayer);\n\n if (result.status !== UserResponseStatus.APPROVED) {\n throw new UserRejectedError({ action: 'signTransaction' });\n }\n\n return {\n signature: result.args,\n };\n };\n\n const signAndSubmitTransaction: AptosWalletProvider['signAndSubmitTransaction'] =\n async ({ transaction, walletAccount }) => {\n await assertWalletAccountSigningAvailability(\n { walletAccount },\n dynamicClient\n );\n\n const signAndSubmitMethod =\n features['aptos:signAndSubmitTransaction']?.signAndSubmitTransaction;\n\n assertDefined(\n signAndSubmitMethod,\n 'signAndSubmitTransaction method not found in wallet features'\n );\n\n const result = await signAndSubmitMethod({\n payload: transaction,\n });\n\n if (result.status !== UserResponseStatus.APPROVED) {\n throw new UserRejectedError({ action: 'signAndSubmitTransaction' });\n }\n\n return {\n hash: result.args.hash,\n };\n };\n\n const signMessage: AptosWalletProvider['signMessage'] = async ({\n message,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account not found');\n\n await assertWalletAccountSigningAvailability(\n { walletAccount },\n dynamicClient\n );\n\n const signMessageMethod = features['aptos:signMessage']?.signMessage;\n\n assertDefined(\n signMessageMethod,\n 'signMessage method not found in wallet features'\n );\n\n const nonce = Date.now().toString();\n const result = await signMessageMethod({\n message,\n nonce,\n });\n\n if (result.status !== UserResponseStatus.APPROVED) {\n throw new UserRejectedError({ action: 'signMessage' });\n }\n\n let publicKey: string | undefined =\n walletStandardWallet.accounts[0]?.publicKey?.toString();\n\n if (!publicKey) {\n const account = await getConnectedAccount();\n publicKey = account?.publicKey?.toString();\n }\n\n const signatureObj = {\n fullMessage: result.args.fullMessage,\n publicKey,\n signature: result.args.signature.toString(),\n };\n\n return { signature: JSON.stringify(signatureObj) };\n };\n\n const { cleanupEventEmitter, getEventEmitter } =\n createWalletProviderEventEmitter<VoidFunction>({\n removeEventListeners: ({ setupReturnValue }) => {\n assertDefined(setupReturnValue, 'Setup return value not defined');\n\n setupReturnValue();\n },\n\n setupEventListeners: ({\n handleAccountsChanged,\n handleNetworkChanged,\n }): VoidFunction => {\n const onAccountChange =\n features['aptos:onAccountChange']?.onAccountChange;\n\n if (onAccountChange) {\n void onAccountChange((account) => {\n handleAccountsChanged({\n addresses: account ? [account.address.toString()] : [],\n });\n });\n }\n\n const onNetworkChange =\n features['aptos:onNetworkChange']?.onNetworkChange;\n\n if (onNetworkChange) {\n void onNetworkChange((network) => {\n handleNetworkChanged({ networkId: network.chainId.toString() });\n });\n }\n\n return () => {};\n },\n\n supportedEvents: ['accountsChanged', 'networkChanged'],\n });\n\n const destroy: AptosWalletProvider['destroy'] = async () => {\n cleanupEventEmitter();\n try {\n const disconnectMethod = features['aptos:disconnect']?.disconnect;\n\n // this should never happen as we check for all required features in hasAllRequiredFeatures\n // but we'll assert it just in case\n assertDefined(\n disconnectMethod,\n 'disconnect method not found in wallet features'\n );\n\n await disconnectMethod();\n } catch (err) {\n getCore(dynamicClient).logger.error(\n `[${key}] destroy: remote signal failed`,\n err\n );\n }\n };\n\n const walletProvider: AptosWalletProvider = {\n chain: 'APTOS',\n connect,\n destroy,\n get events() {\n return getEventEmitter();\n },\n getActiveNetworkId,\n getAptosClient,\n getConnectedAddresses,\n groupKey: formatWalletProviderGroupKey(walletStandardWallet.name),\n key,\n metadata: {\n displayName: walletStandardWallet.name,\n icon: walletStandardWallet.icon,\n },\n signAndSubmitTransaction,\n signMessage,\n signTransaction,\n transferAmount: (args) => aptosTransferAmount(args, dynamicClient),\n walletProviderType,\n };\n\n return walletProvider;\n};\n","import type {\n AptosWallet,\n MinimallyRequiredFeatures,\n} from '@aptos-labs/wallet-standard';\n\nconst REQUIRED_FEATURES: (keyof MinimallyRequiredFeatures)[] = [\n 'aptos:account',\n 'aptos:connect',\n 'aptos:disconnect',\n 'aptos:network',\n 'aptos:onAccountChange',\n 'aptos:onNetworkChange',\n 'aptos:signMessage',\n 'aptos:signTransaction',\n];\n\n/** @notInstrumented */\nexport const hasAllRequiredFeatures = (wallet: AptosWallet): boolean => {\n return Boolean(\n REQUIRED_FEATURES.every((feature) => feature in wallet.features)\n );\n};\n","import type { AptosWallet } from '@aptos-labs/wallet-standard';\nimport type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n getWalletProviderRegistry,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createWalletProviderFromAptosStandardWallet } from '../createWalletProviderFromAptosStandardWallet';\nimport { hasAllRequiredFeatures } from '../hasAllRequiredFeatures';\n\n/** @notInstrumented */\nexport const registerAptosStandardWallet = (\n wallet: AptosWallet,\n client: DynamicClient\n) => {\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n if (hasAllRequiredFeatures(wallet)) {\n const walletProvider = createWalletProviderFromAptosStandardWallet({\n dynamicClient: client,\n walletStandardWallet: wallet,\n });\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SELF_ANNOUNCEMENT_STANDARD,\n walletProvider,\n });\n }\n};\n","import type { AptosWallet } from '@aptos-labs/wallet-standard';\nimport { getAptosWallets } from '@aptos-labs/wallet-standard';\nimport {\n getDefaultClient,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { registerAptosNetworkProviderBuilder } from '../../registerAptosNetworkProviderBuilder';\nimport { registerAptosStandardWallet } from '../utils/registerAptosStandardWallet';\n\nexport const APTOS_WALLET_STANDARD_EXTENSION_KEY = 'aptosWalletStandard';\n\n/**\n * Adds the Aptos Wallet Standard extension to the Dynamic client.\n *\n * This extension enables integration with wallets that implement the Aptos Wallet Standard (AIP-62),\n * automatically detecting and registering compatible wallets for use with the Dynamic SDK.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n *\n * @returns A function that can be used to remove Aptos Wallet Standard register event listener that was added.\n * @notInstrumented\n */\nexport const addAptosWalletStandardExtension = (\n client = getDefaultClient()\n): VoidFunction => {\n if (\n hasExtension({ extensionKey: APTOS_WALLET_STANDARD_EXTENSION_KEY }, client)\n ) {\n return () => {\n // noop\n };\n }\n\n registerExtension(\n { extensionKey: APTOS_WALLET_STANDARD_EXTENSION_KEY },\n client\n );\n\n registerAptosNetworkProviderBuilder(client);\n\n const { aptosWallets, on } = getAptosWallets();\n\n // Listen for new wallet registrations/announcements\n const removeListener = on('register', (wallet) => {\n registerAptosStandardWallet(wallet as AptosWallet, client);\n });\n\n // Register all wallets that are already registered/announced in the browser\n for (const wallet of aptosWallets) {\n registerAptosStandardWallet(wallet, client);\n }\n\n return removeListener;\n};\n"],"mappings":";;;;;;;;;;;;ACCA,MAAa,gBAAgB;;;;;ACW7B,MAAa,oBAAoB,OAAO,EACtC,SACA,kBACqD;CAQrD,MAAM,UAAU,MAFI,IAAIA,yBALT,IAAIC,+BAAY;EAC7B,UAAU,YAAY,QAAQ,KAAK;EACnC,SAAS,YAAY;EACtB,CAAC,CAEmC,CAEH,WAAW;EAC3C,gBAAgB;EAEhB,OAAO;EACR,CAAC;AAEF,SAAQ,OAAO,QAAQ,GAAG,eAAe,UAAU;;;;;;ACtBrD,MAAa,8BACX,iBAC0B;CAC1B,gEAA6B,SAAS,YAAY;CAClD,SAAS,YAAY;CACrB,YAAY,OAAO,EAAE,eAAe,EAClC,SAAS,MAAM,kBAAkB;EAC/B;EACA;EACD,CAAC,EACH;CACF;;;;;ACZD,MAAa,uCACX,WACS;CACT,MAAM,sGAC8B,OAAO;AAG3C,KAAI,+BAA+B,KAAK,CAAC,I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ACA;CACA;CACA;CACA;CACA;CACD;;AAGD,MAAa,0BAA0B,WAAiC;AACtE,QAAO,QACL,kBAAkB,OAAO,YAAY,WAAW,OAAO,SAAS,CACjE;;;;;;ACTH,MAAa,+BACX,QACA,WACG;CACH,MAAM,sFAAmD,OAAO;AAEhE,KAAI,uBAAuB,OAAO,EAAE;EAClC,MAAM,iBAAiB,4CAA4C;GACjE,eAAe;GACf,sBAAsB;GACvB,CAAC;AAEF,yBAAuB,SAAS;GAC9B,UAAUC,qDAAuB;GACjC;GACD,CAAC;;;;;;ACfN,MAAa,sCAAsC;;;;;;;;;;;;AAanD,MAAa,mCACX,8DAA2B,KACV;AACjB,qDACe,EAAE,cAAc,qCAAqC,EAAE,OAAO,CAE3E,cAAa;AAKf,sDACE,EAAE,cAAc,qCAAqC,EACrD,OACD;AAED,qCAAoC,OAAO;CAE3C,MAAM,EAAE,cAAc,yDAAwB;CAG9C,MAAM,iBAAiB,GAAG,aAAa,WAAW;AAChD,8BAA4B,QAAuB,OAAO;GAC1D;AAGF,MAAK,MAAM,UAAU,aACnB,6BAA4B,QAAQ,OAAO;AAG7C,QAAO"}
@@ -6,7 +6,7 @@ import { WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
6
6
 
7
7
  //#region package.json
8
8
  var name = "@dynamic-labs-sdk/aptos";
9
- var version = "1.17.1";
9
+ var version = "1.19.0";
10
10
 
11
11
  //#endregion
12
12
  //#region src/utils/constants.ts
@@ -68,12 +68,41 @@ var NotAptosProviderError = class extends BaseError {
68
68
 
69
69
  //#endregion
70
70
  //#region src/isAptosWalletAccount/isAptosWalletAccount.ts
71
- /** @notInstrumented */
71
+ /**
72
+ * Type guard function to check if a wallet account is an Aptos wallet account.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const accounts = getWalletAccounts();
77
+ * const aptosAccounts = accounts.filter(isAptosWalletAccount);
78
+ * ```
79
+ *
80
+ * @param walletAccount - The wallet account to check.
81
+ * @returns True if the wallet account is an Aptos wallet account, false otherwise.
82
+ * @see isAptosNetworkProvider
83
+ * @see addAptosExtension
84
+ * @notInstrumented
85
+ */
72
86
  const isAptosWalletAccount = (walletAccount) => walletAccount.chain === "APTOS";
73
87
 
74
88
  //#endregion
75
89
  //#region src/isAptosWalletProvider/isAptosWalletProvider.ts
76
- /** @notInstrumented */
90
+ /**
91
+ * Type guard function to check if a wallet provider is an Aptos wallet provider.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * if (isAptosWalletProvider(provider)) {
96
+ * const aptosClient = await provider.getAptosClient();
97
+ * }
98
+ * ```
99
+ *
100
+ * @param provider - The wallet provider to check.
101
+ * @returns True if the wallet provider is an Aptos wallet provider, false otherwise.
102
+ * @see isAptosWalletAccount
103
+ * @see addAptosExtension
104
+ * @notInstrumented
105
+ */
77
106
  const isAptosWalletProvider = (provider) => {
78
107
  return provider.chain === "APTOS";
79
108
  };
@@ -327,4 +356,4 @@ const addAptosWalletStandardExtension = (client = getDefaultClient()) => {
327
356
 
328
357
  //#endregion
329
358
  export { name as a, NotAptosProviderError as i, isAptosWalletProvider as n, version as o, isAptosWalletAccount as r, addAptosWalletStandardExtension as t };
330
- //# sourceMappingURL=addAptosWalletStandardExtension-jiIkABI0.esm.js.map
359
+ //# sourceMappingURL=addAptosWalletStandardExtension-Drme8SEO.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addAptosWalletStandardExtension-Drme8SEO.esm.js","names":["transaction: AptosTransactionPayload","features: AptosFeatures","connect: AptosWalletProvider['connect']","getActiveNetworkId: AptosWalletProvider['getActiveNetworkId']","getAptosClient: AptosWalletProvider['getAptosClient']","getConnectedAddresses: AptosWalletProvider['getConnectedAddresses']","signTransaction: AptosWalletProvider['signTransaction']","signAndSubmitTransaction: AptosWalletProvider['signAndSubmitTransaction']","signMessage: AptosWalletProvider['signMessage']","publicKey: string | undefined","destroy: AptosWalletProvider['destroy']","REQUIRED_FEATURES: (keyof MinimallyRequiredFeatures)[]"],"sources":["../package.json","../src/utils/constants.ts","../src/utils/fetchAptosBalance/fetchAptosBalance.ts","../src/utils/createAptosNetworkProvider/createAptosNetworkProvider.ts","../src/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.ts","../src/errors/NotAptosProviderError/NotAptosProviderError.ts","../src/isAptosWalletAccount/isAptosWalletAccount.ts","../src/isAptosWalletProvider/isAptosWalletProvider.ts","../src/utils/aptosTransferAmount/aptosTransferAmount.ts","../src/walletStandard/utils/createWalletProviderFromAptosStandardWallet/createWalletProviderFromAptosStandardWallet.ts","../src/walletStandard/utils/hasAllRequiredFeatures/hasAllRequiredFeatures.ts","../src/walletStandard/utils/registerAptosStandardWallet/registerAptosStandardWallet.ts","../src/walletStandard/addAptosWalletStandardExtension/addAptosWalletStandardExtension.ts"],"sourcesContent":["","// 1 APT = 10^8 octas (similar to 1 BTC = 10^8 satoshis)\nexport const OCTAS_PER_APT = 1e8;\n","import type { Network } from '@aptos-labs/ts-sdk';\nimport { Aptos, AptosConfig } from '@aptos-labs/ts-sdk';\nimport type { NetworkData } from '@dynamic-labs-sdk/client';\n\nimport { OCTAS_PER_APT } from '../constants';\n\ntype FetchAptosBalanceParams = {\n address: string;\n networkData: NetworkData;\n};\n\n/** @notInstrumented */\nexport const fetchAptosBalance = async ({\n address,\n networkData,\n}: FetchAptosBalanceParams): Promise<string | null> => {\n const config = new AptosConfig({\n fullnode: networkData.rpcUrls.http[0],\n network: networkData.cluster as Network,\n });\n\n const aptosClient = new Aptos(config);\n\n const balance = await aptosClient.getBalance({\n accountAddress: address,\n // APT coin type\n asset: '0x1::aptos_coin::AptosCoin',\n });\n\n return (Number(balance) / OCTAS_PER_APT).toString();\n};\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport { createBaseNetworkProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosNetworkProvider } from '../../AptosNetworkProvider.types';\nimport { fetchAptosBalance } from '../fetchAptosBalance';\n\n/** @notInstrumented */\nexport const createAptosNetworkProvider = (\n networkData: NetworkData\n): AptosNetworkProvider => ({\n ...createBaseNetworkProvider('APTOS', networkData),\n cluster: networkData.cluster,\n getBalance: async ({ address }) => ({\n balance: await fetchAptosBalance({\n address,\n networkData,\n }),\n }),\n});\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getNetworkProviderBuilderRegistry } from '@dynamic-labs-sdk/client/core';\n\nimport { createAptosNetworkProvider } from '../utils/createAptosNetworkProvider';\n\n/** @notInstrumented */\nexport const registerAptosNetworkProviderBuilder = (\n client: DynamicClient\n): void => {\n const networkProviderBuilderRegistry =\n getNetworkProviderBuilderRegistry(client);\n\n // If the Aptos network provider builder is already registered, return.\n if (networkProviderBuilderRegistry.get().get('APTOS')) {\n return;\n }\n\n networkProviderBuilderRegistry.register({\n builder: createAptosNetworkProvider,\n chain: 'APTOS',\n });\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class NotAptosProviderError extends BaseError {\n public readonly providerKey: string;\n\n constructor(params: { providerKey: string }) {\n super({\n cause: null,\n code: 'not_aptos_provider_error',\n docsUrl: null,\n name: 'NotAptosProviderError',\n shortMessage: 'Provider is not an Aptos wallet provider',\n });\n\n this.providerKey = params.providerKey;\n }\n}\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { AptosWalletAccount } from '../AptosWalletAccount.types';\n\n/**\n * Type guard function to check if a wallet account is an Aptos wallet account.\n *\n * @example\n * ```ts\n * const accounts = getWalletAccounts();\n * const aptosAccounts = accounts.filter(isAptosWalletAccount);\n * ```\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is an Aptos wallet account, false otherwise.\n * @see isAptosNetworkProvider\n * @see addAptosExtension\n * @notInstrumented\n */\nexport const isAptosWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is AptosWalletAccount => walletAccount.chain === 'APTOS';\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosWalletProvider } from '../AptosWalletProvider.types';\n\n/**\n * Type guard function to check if a wallet provider is an Aptos wallet provider.\n *\n * @example\n * ```ts\n * if (isAptosWalletProvider(provider)) {\n * const aptosClient = await provider.getAptosClient();\n * }\n * ```\n *\n * @param provider - The wallet provider to check.\n * @returns True if the wallet provider is an Aptos wallet provider, false otherwise.\n * @see isAptosWalletAccount\n * @see addAptosExtension\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const isAptosWalletProvider = (\n provider: WalletProvider | AptosWalletProvider\n): provider is AptosWalletProvider => {\n return provider.chain === 'APTOS';\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { InvalidParamError } from '@dynamic-labs-sdk/client';\nimport {\n type TransferAmountParams,\n getWalletProviderFromWalletAccount,\n parseAmountToSmallestUnit,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosTransactionPayload } from '../../AptosWalletProvider.types';\nimport { NotAptosProviderError } from '../../errors/NotAptosProviderError';\nimport { isAptosWalletAccount } from '../../isAptosWalletAccount';\nimport { isAptosWalletProvider } from '../../isAptosWalletProvider';\n\nconst APT_DECIMALS = 8;\n\n/**\n * Transfers native APT or fungible tokens from one wallet to another.\n *\n * Converts the human-readable amount string to the smallest unit (octas for APT,\n * or the appropriate unit for fungible tokens) using string-based arithmetic\n * to avoid floating-point precision issues.\n * @notInstrumented\n */\nexport const aptosTransferAmount = async (\n { amount, recipient, token, walletAccount }: TransferAmountParams,\n client: DynamicClient\n): Promise<{ transactionHash: string }> => {\n if (!isAptosWalletAccount(walletAccount)) {\n throw new InvalidParamError(\n 'Wallet account is not an Aptos wallet account'\n );\n }\n\n const provider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (!isAptosWalletProvider(provider)) {\n throw new NotAptosProviderError({ providerKey: provider.key });\n }\n\n const decimals = token?.decimals ?? APT_DECIMALS;\n const smallestUnitAmount = parseAmountToSmallestUnit({ amount, decimals });\n\n let transaction: AptosTransactionPayload;\n if (token?.address) {\n transaction = {\n function: '0x1::primary_fungible_store::transfer',\n functionArguments: [token.address, recipient, Number(smallestUnitAmount)],\n typeArguments: ['0x1::fungible_asset::Metadata'],\n };\n } else {\n transaction = {\n function: '0x1::coin::transfer',\n functionArguments: [recipient, Number(smallestUnitAmount)],\n typeArguments: ['0x1::aptos_coin::AptosCoin'],\n };\n }\n\n const result = await provider.signAndSubmitTransaction({\n transaction,\n walletAccount,\n });\n\n return { transactionHash: result.hash };\n};\n","import type { Network } from '@aptos-labs/ts-sdk';\nimport { Aptos, AptosConfig } from '@aptos-labs/ts-sdk';\nimport type {\n AccountInfo,\n AptosFeatures,\n AptosWallet,\n} from '@aptos-labs/wallet-standard';\nimport { UserResponseStatus } from '@aptos-labs/wallet-standard';\nimport {\n type DynamicClient,\n UserRejectedError,\n assertWalletAccountSigningAvailability,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n createWalletProviderEventEmitter,\n formatWalletProviderGroupKey,\n formatWalletProviderKey,\n getActiveNetworkIdFromLastKnownRegistry,\n getCore,\n} from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { AptosWalletProvider } from '../../../AptosWalletProvider.types';\nimport { aptosTransferAmount } from '../../../utils/aptosTransferAmount';\n\ntype CreateWalletProviderFromAptosStandardWalletParams = {\n dynamicClient: DynamicClient;\n walletStandardWallet: AptosWallet;\n};\n\n/** @notInstrumented */\nexport const createWalletProviderFromAptosStandardWallet = ({\n dynamicClient,\n walletStandardWallet,\n}: CreateWalletProviderFromAptosStandardWalletParams): AptosWalletProvider => {\n const features: AptosFeatures = walletStandardWallet.features;\n\n const walletProviderType = WalletProviderEnum.BrowserExtension;\n\n const key = formatWalletProviderKey({\n chain: 'APTOS',\n displayName: walletStandardWallet.name,\n walletProviderType,\n });\n\n const getAutoConnectedAccount = ():\n | { address: string; publicKey: string }[]\n | undefined => {\n const accounts = walletStandardWallet.accounts;\n if (!accounts?.length || !accounts[0].publicKey || !accounts[0].address) {\n return;\n }\n\n return accounts.map((account) => ({\n address: account.address.toString(),\n publicKey: account.publicKey?.toString(),\n }));\n };\n\n const connect: AptosWalletProvider['connect'] = async () => {\n const autoConnectedAccounts = getAutoConnectedAccount();\n\n if (autoConnectedAccounts) {\n return {\n addresses: autoConnectedAccounts,\n };\n }\n\n const connectMethod = features['aptos:connect']?.connect;\n\n assertDefined(connectMethod, 'connect method not found in wallet features');\n\n const result = await connectMethod();\n\n if (result.status !== UserResponseStatus.APPROVED) {\n throw new UserRejectedError({ action: 'connect' });\n }\n\n return {\n addresses: [\n {\n address: result.args.address.toString(),\n publicKey: result.args.publicKey?.toString(),\n },\n ],\n };\n };\n\n const getActiveNetworkId: AptosWalletProvider['getActiveNetworkId'] =\n async () => {\n const aptosNetwork = await features['aptos:network']?.network();\n\n if (!aptosNetwork?.chainId) {\n return getActiveNetworkIdFromLastKnownRegistry({\n client: dynamicClient,\n walletProviderKey: key,\n });\n }\n\n return { networkId: aptosNetwork.chainId.toString() };\n };\n\n const getAptosClient: AptosWalletProvider['getAptosClient'] = async ({\n walletAccount,\n }) => {\n const activeNetworkData = await getActiveNetworkData(\n { walletAccount },\n dynamicClient\n );\n\n assertDefined(\n activeNetworkData.networkData,\n 'No active network data found'\n );\n\n const { rpcUrls, cluster } = activeNetworkData.networkData;\n\n const url = rpcUrls.http[0];\n\n assertDefined(url, 'No RPC URL found for active network');\n\n const network = cluster as Network;\n const config = new AptosConfig({ fullnode: url, network });\n\n return new Aptos(config);\n };\n\n const getConnectedAccount = async (): Promise<AccountInfo | undefined> => {\n const getAccountMethod = features['aptos:account']?.account;\n\n if (!getAccountMethod) {\n return undefined;\n }\n\n return getAccountMethod();\n };\n\n const getConnectedAddresses: AptosWalletProvider['getConnectedAddresses'] =\n async () => {\n const account = await getConnectedAccount();\n\n if (account) {\n return {\n addresses: [account.address.toString()],\n };\n }\n\n return {\n addresses: [],\n };\n };\n\n const signTransaction: AptosWalletProvider['signTransaction'] = async ({\n asFeePayer,\n transaction,\n walletAccount,\n }) => {\n await assertWalletAccountSigningAvailability(\n { walletAccount },\n dynamicClient\n );\n\n const signTransactionMethod =\n features['aptos:signTransaction']?.signTransaction;\n\n assertDefined(\n signTransactionMethod,\n 'signTransaction method not found in wallet features'\n );\n\n const result = await signTransactionMethod(transaction, asFeePayer);\n\n if (result.status !== UserResponseStatus.APPROVED) {\n throw new UserRejectedError({ action: 'signTransaction' });\n }\n\n return {\n signature: result.args,\n };\n };\n\n const signAndSubmitTransaction: AptosWalletProvider['signAndSubmitTransaction'] =\n async ({ transaction, walletAccount }) => {\n await assertWalletAccountSigningAvailability(\n { walletAccount },\n dynamicClient\n );\n\n const signAndSubmitMethod =\n features['aptos:signAndSubmitTransaction']?.signAndSubmitTransaction;\n\n assertDefined(\n signAndSubmitMethod,\n 'signAndSubmitTransaction method not found in wallet features'\n );\n\n const result = await signAndSubmitMethod({\n payload: transaction,\n });\n\n if (result.status !== UserResponseStatus.APPROVED) {\n throw new UserRejectedError({ action: 'signAndSubmitTransaction' });\n }\n\n return {\n hash: result.args.hash,\n };\n };\n\n const signMessage: AptosWalletProvider['signMessage'] = async ({\n message,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account not found');\n\n await assertWalletAccountSigningAvailability(\n { walletAccount },\n dynamicClient\n );\n\n const signMessageMethod = features['aptos:signMessage']?.signMessage;\n\n assertDefined(\n signMessageMethod,\n 'signMessage method not found in wallet features'\n );\n\n const nonce = Date.now().toString();\n const result = await signMessageMethod({\n message,\n nonce,\n });\n\n if (result.status !== UserResponseStatus.APPROVED) {\n throw new UserRejectedError({ action: 'signMessage' });\n }\n\n let publicKey: string | undefined =\n walletStandardWallet.accounts[0]?.publicKey?.toString();\n\n if (!publicKey) {\n const account = await getConnectedAccount();\n publicKey = account?.publicKey?.toString();\n }\n\n const signatureObj = {\n fullMessage: result.args.fullMessage,\n publicKey,\n signature: result.args.signature.toString(),\n };\n\n return { signature: JSON.stringify(signatureObj) };\n };\n\n const { cleanupEventEmitter, getEventEmitter } =\n createWalletProviderEventEmitter<VoidFunction>({\n removeEventListeners: ({ setupReturnValue }) => {\n assertDefined(setupReturnValue, 'Setup return value not defined');\n\n setupReturnValue();\n },\n\n setupEventListeners: ({\n handleAccountsChanged,\n handleNetworkChanged,\n }): VoidFunction => {\n const onAccountChange =\n features['aptos:onAccountChange']?.onAccountChange;\n\n if (onAccountChange) {\n void onAccountChange((account) => {\n handleAccountsChanged({\n addresses: account ? [account.address.toString()] : [],\n });\n });\n }\n\n const onNetworkChange =\n features['aptos:onNetworkChange']?.onNetworkChange;\n\n if (onNetworkChange) {\n void onNetworkChange((network) => {\n handleNetworkChanged({ networkId: network.chainId.toString() });\n });\n }\n\n return () => {};\n },\n\n supportedEvents: ['accountsChanged', 'networkChanged'],\n });\n\n const destroy: AptosWalletProvider['destroy'] = async () => {\n cleanupEventEmitter();\n try {\n const disconnectMethod = features['aptos:disconnect']?.disconnect;\n\n // this should never happen as we check for all required features in hasAllRequiredFeatures\n // but we'll assert it just in case\n assertDefined(\n disconnectMethod,\n 'disconnect method not found in wallet features'\n );\n\n await disconnectMethod();\n } catch (err) {\n getCore(dynamicClient).logger.error(\n `[${key}] destroy: remote signal failed`,\n err\n );\n }\n };\n\n const walletProvider: AptosWalletProvider = {\n chain: 'APTOS',\n connect,\n destroy,\n get events() {\n return getEventEmitter();\n },\n getActiveNetworkId,\n getAptosClient,\n getConnectedAddresses,\n groupKey: formatWalletProviderGroupKey(walletStandardWallet.name),\n key,\n metadata: {\n displayName: walletStandardWallet.name,\n icon: walletStandardWallet.icon,\n },\n signAndSubmitTransaction,\n signMessage,\n signTransaction,\n transferAmount: (args) => aptosTransferAmount(args, dynamicClient),\n walletProviderType,\n };\n\n return walletProvider;\n};\n","import type {\n AptosWallet,\n MinimallyRequiredFeatures,\n} from '@aptos-labs/wallet-standard';\n\nconst REQUIRED_FEATURES: (keyof MinimallyRequiredFeatures)[] = [\n 'aptos:account',\n 'aptos:connect',\n 'aptos:disconnect',\n 'aptos:network',\n 'aptos:onAccountChange',\n 'aptos:onNetworkChange',\n 'aptos:signMessage',\n 'aptos:signTransaction',\n];\n\n/** @notInstrumented */\nexport const hasAllRequiredFeatures = (wallet: AptosWallet): boolean => {\n return Boolean(\n REQUIRED_FEATURES.every((feature) => feature in wallet.features)\n );\n};\n","import type { AptosWallet } from '@aptos-labs/wallet-standard';\nimport type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n WalletProviderPriority,\n getWalletProviderRegistry,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { createWalletProviderFromAptosStandardWallet } from '../createWalletProviderFromAptosStandardWallet';\nimport { hasAllRequiredFeatures } from '../hasAllRequiredFeatures';\n\n/** @notInstrumented */\nexport const registerAptosStandardWallet = (\n wallet: AptosWallet,\n client: DynamicClient\n) => {\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n if (hasAllRequiredFeatures(wallet)) {\n const walletProvider = createWalletProviderFromAptosStandardWallet({\n dynamicClient: client,\n walletStandardWallet: wallet,\n });\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SELF_ANNOUNCEMENT_STANDARD,\n walletProvider,\n });\n }\n};\n","import type { AptosWallet } from '@aptos-labs/wallet-standard';\nimport { getAptosWallets } from '@aptos-labs/wallet-standard';\nimport {\n getDefaultClient,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { registerAptosNetworkProviderBuilder } from '../../registerAptosNetworkProviderBuilder';\nimport { registerAptosStandardWallet } from '../utils/registerAptosStandardWallet';\n\nexport const APTOS_WALLET_STANDARD_EXTENSION_KEY = 'aptosWalletStandard';\n\n/**\n * Adds the Aptos Wallet Standard extension to the Dynamic client.\n *\n * This extension enables integration with wallets that implement the Aptos Wallet Standard (AIP-62),\n * automatically detecting and registering compatible wallets for use with the Dynamic SDK.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n *\n * @returns A function that can be used to remove Aptos Wallet Standard register event listener that was added.\n * @notInstrumented\n */\nexport const addAptosWalletStandardExtension = (\n client = getDefaultClient()\n): VoidFunction => {\n if (\n hasExtension({ extensionKey: APTOS_WALLET_STANDARD_EXTENSION_KEY }, client)\n ) {\n return () => {\n // noop\n };\n }\n\n registerExtension(\n { extensionKey: APTOS_WALLET_STANDARD_EXTENSION_KEY },\n client\n );\n\n registerAptosNetworkProviderBuilder(client);\n\n const { aptosWallets, on } = getAptosWallets();\n\n // Listen for new wallet registrations/announcements\n const removeListener = on('register', (wallet) => {\n registerAptosStandardWallet(wallet as AptosWallet, client);\n });\n\n // Register all wallets that are already registered/announced in the browser\n for (const wallet of aptosWallets) {\n registerAptosStandardWallet(wallet, client);\n }\n\n return removeListener;\n};\n"],"mappings":";;;;;;;;;;;;ACCA,MAAa,gBAAgB;;;;;ACW7B,MAAa,oBAAoB,OAAO,EACtC,SACA,kBACqD;CAQrD,MAAM,UAAU,MAFI,IAAI,MALT,IAAI,YAAY;EAC7B,UAAU,YAAY,QAAQ,KAAK;EACnC,SAAS,YAAY;EACtB,CAAC,CAEmC,CAEH,WAAW;EAC3C,gBAAgB;EAEhB,OAAO;EACR,CAAC;AAEF,SAAQ,OAAO,QAAQ,GAAG,eAAe,UAAU;;;;;;ACtBrD,MAAa,8BACX,iBAC0B;CAC1B,GAAG,0BAA0B,SAAS,YAAY;CAClD,SAAS,YAAY;CACrB,YAAY,OAAO,EAAE,eAAe,EAClC,SAAS,MAAM,kBAAkB;EAC/B;EACA;EACD,CAAC,EACH;CACF;;;;;ACZD,MAAa,uCACX,WACS;CACT,MAAM,iCACJ,kCAAkC,OAAO;AAG3C,KAAI,+BAA+B,KAAK,CAAC,IAAI,QAAQ,CACnD;AAGF,gCAA+B,SAAS;EACtC,SAAS;EACT,OAAO;EACR,CAAC;;;;;AClBJ,IAAa,wBAAb,cAA2C,UAAU;CACnD,AAAgB;CAEhB,YAAY,QAAiC;AAC3C,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;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0B,OAAO;AAEhE,KAAI,uBAAuB,OAAO,EAAE;EAClC,MAAM,iBAAiB,4CAA4C;GACjE,eAAe;GACf,sBAAsB;GACvB,CAAC;AAEF,yBAAuB,SAAS;GAC9B,UAAU,uBAAuB;GACjC;GACD,CAAC;;;;;;ACfN,MAAa,sCAAsC;;;;;;;;;;;;AAanD,MAAa,mCACX,SAAS,kBAAkB,KACV;AACjB,KACE,aAAa,EAAE,cAAc,qCAAqC,EAAE,OAAO,CAE3E,cAAa;AAKf,mBACE,EAAE,cAAc,qCAAqC,EACrD,OACD;AAED,qCAAoC,OAAO;CAE3C,MAAM,EAAE,cAAc,OAAO,iBAAiB;CAG9C,MAAM,iBAAiB,GAAG,aAAa,WAAW;AAChD,8BAA4B,QAAuB,OAAO;GAC1D;AAGF,MAAK,MAAM,UAAU,aACnB,6BAA4B,QAAQ,OAAO;AAG7C,QAAO"}
@@ -6,12 +6,18 @@ type GetAptosClientParams = {
6
6
  /**
7
7
  * Retrieves an Aptos client from a wallet account.
8
8
  *
9
+ * @example
10
+ * ```ts
11
+ * const aptosClient = await getAptosClient({ walletAccount: aptosAccount });
12
+ * ```
13
+ *
9
14
  * @param params.walletAccount - The wallet account to get the Aptos client for.
10
15
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
11
- *
12
- * @returns A promise that resolves to an AptosClient instance
13
- * @throws NotAptosProviderError If the wallet account's provider is not an APTOS provider
14
- * @notInstrumented
16
+ * @returns A promise that resolves to an AptosClient instance.
17
+ * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.
18
+ * @see signAndSubmitTransaction
19
+ * @see isAptosWalletAccount
20
+ * @notInstrumented
15
21
  */
16
22
  export declare const getAptosClient: ({ walletAccount }: GetAptosClientParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<AptosClient>;
17
23
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"getAptosClient.d.ts","sourceRoot":"","sources":["../../src/getAptosClient/getAptosClient.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAIhE,KAAK,oBAAoB,GAAG;IAC1B,aAAa,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,sBACN,oBAAoB,gEAEtC,OAAO,CAAC,WAAW,CAarB,CAAC"}
1
+ {"version":3,"file":"getAptosClient.d.ts","sourceRoot":"","sources":["../../src/getAptosClient/getAptosClient.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAIhE,KAAK,oBAAoB,GAAG;IAC1B,aAAa,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,sBACN,oBAAoB,gEAEtC,OAAO,CAAC,WAAW,CAarB,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_addAptosWalletStandardExtension = require('./addAptosWalletStandardExtension-BeX9GJpF.cjs');
1
+ const require_addAptosWalletStandardExtension = require('./addAptosWalletStandardExtension-CJmRqCMM.cjs');
2
2
  let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
3
3
  let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
4
4
  let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
@@ -10,7 +10,16 @@ let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
10
10
  * This is a convenience function that adds support for all of Aptos wallets that support the Aptos Wallet Standard,
11
11
  * like Petra, Backpack, OKX, Nightly, and more.
12
12
  *
13
+ * @example
14
+ * ```ts
15
+ * const client = createDynamicClient({ environmentId: 'env-123' });
16
+ * addAptosExtension(client);
17
+ * ```
18
+ *
13
19
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
20
+ * @returns void
21
+ * @see isAptosWalletAccount
22
+ * @see isAptosNetworkProvider
14
23
  * @notInstrumented
15
24
  */
16
25
  const addAptosExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
@@ -22,11 +31,17 @@ const addAptosExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefault
22
31
  /**
23
32
  * Retrieves an Aptos client from a wallet account.
24
33
  *
34
+ * @example
35
+ * ```ts
36
+ * const aptosClient = await getAptosClient({ walletAccount: aptosAccount });
37
+ * ```
38
+ *
25
39
  * @param params.walletAccount - The wallet account to get the Aptos client for.
26
40
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
27
- *
28
- * @returns A promise that resolves to an AptosClient instance
29
- * @throws NotAptosProviderError If the wallet account's provider is not an APTOS provider
41
+ * @returns A promise that resolves to an AptosClient instance.
42
+ * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.
43
+ * @see signAndSubmitTransaction
44
+ * @see isAptosWalletAccount
30
45
  * @notInstrumented
31
46
  */
32
47
  const getAptosClient = async ({ walletAccount }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
@@ -37,19 +52,44 @@ const getAptosClient = async ({ walletAccount }, client = (0, _dynamic_labs_sdk_
37
52
 
38
53
  //#endregion
39
54
  //#region src/isAptosNetworkProvider/isAptosNetworkProvider.ts
40
- /** @notInstrumented */
55
+ /**
56
+ * Type guard function to check if a network provider is an Aptos network provider.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * if (isAptosNetworkProvider(networkProvider)) {
61
+ * const aptosClient = networkProvider.getAptosClient();
62
+ * }
63
+ * ```
64
+ *
65
+ * @param networkProvider - The network provider to check.
66
+ * @returns True if the network provider is an Aptos network provider, false otherwise.
67
+ * @see isAptosWalletAccount
68
+ * @see addAptosExtension
69
+ * @notInstrumented
70
+ */
41
71
  const isAptosNetworkProvider = (networkProvider) => networkProvider.chain === "APTOS";
42
72
 
43
73
  //#endregion
44
74
  //#region src/signAndSubmitTransaction/signAndSubmitTransaction.ts
45
75
  /**
46
- * Signs and submits an Aptos transaction
76
+ * Signs and submits an Aptos transaction.
47
77
  *
48
- * @param params.transaction - The transaction payload to sign and submit
49
- * @param params.walletAccount - The wallet account to sign the transaction with
50
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
78
+ * @example
79
+ * ```ts
80
+ * const { hash } = await signAndSubmitTransaction({
81
+ * walletAccount: aptosAccount,
82
+ * transaction: { function: '0x1::coin::transfer', arguments: ['0x...', 1000] },
83
+ * });
84
+ * ```
51
85
  *
52
- * @returns An object containing the transaction hash
86
+ * @param params.transaction - The transaction payload to sign and submit.
87
+ * @param params.walletAccount - The wallet account to sign the transaction with.
88
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
89
+ * @returns An object containing the transaction hash.
90
+ * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.
91
+ * @see signTransaction
92
+ * @see getAptosClient
53
93
  * @notInstrumented
54
94
  */
55
95
  const signAndSubmitTransaction = async ({ transaction, walletAccount }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
@@ -64,13 +104,24 @@ const signAndSubmitTransaction = async ({ transaction, walletAccount }, client =
64
104
  //#endregion
65
105
  //#region src/signTransaction/signTransaction.ts
66
106
  /**
67
- * Signs an Aptos transaction
68
- * @param params.transaction - The transaction to sign
69
- * @param params.walletAccount - The wallet account to sign the transaction with
70
- * @param params.asFeePayer - Whether to sign as the fee payer
71
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
107
+ * Signs an Aptos transaction without submitting it.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const { signature } = await signTransaction({
112
+ * walletAccount: aptosAccount,
113
+ * transaction: aptosTransaction,
114
+ * });
115
+ * ```
72
116
  *
73
- * @returns An object containing the signature output
117
+ * @param params.transaction - The transaction to sign.
118
+ * @param params.walletAccount - The wallet account to sign the transaction with.
119
+ * @param [params.asFeePayer] - Whether to sign as the fee payer.
120
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
121
+ * @returns An object containing the signature output.
122
+ * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.
123
+ * @see signAndSubmitTransaction
124
+ * @see getAptosClient
74
125
  * @notInstrumented
75
126
  */
76
127
  const signTransaction = async ({ asFeePayer, transaction, walletAccount }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["isAptosWalletProvider","NotAptosProviderError","isAptosWalletProvider","NotAptosProviderError","isAptosWalletProvider","NotAptosProviderError","packageName","packageVersion"],"sources":["../src/addAptosExtension/addAptosExtension.ts","../src/getAptosClient/getAptosClient.ts","../src/isAptosNetworkProvider/isAptosNetworkProvider.ts","../src/signAndSubmitTransaction/signAndSubmitTransaction.ts","../src/signTransaction/signTransaction.ts","../src/exports/index.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\n\nimport { addAptosWalletStandardExtension } from '../walletStandard/addAptosWalletStandardExtension';\n\n/**\n * Adds the Aptos extension to the Dynamic client.\n *\n * This is a convenience function that adds support for all of Aptos wallets that support the Aptos Wallet Standard,\n * like Petra, Backpack, OKX, Nightly, and more.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @notInstrumented\n */\nexport const addAptosExtension = (client = getDefaultClient()): void => {\n addAptosWalletStandardExtension(client);\n};\n","import {\n getDefaultClient,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosWalletAccount } from '../AptosWalletAccount.types';\nimport type { AptosClient } from '../AptosWalletProvider.types';\nimport { NotAptosProviderError } from '../errors/NotAptosProviderError';\nimport { isAptosWalletProvider } from '../isAptosWalletProvider';\n\ntype GetAptosClientParams = {\n walletAccount: AptosWalletAccount;\n};\n\n/**\n * Retrieves an Aptos client from a wallet account.\n *\n * @param params.walletAccount - The wallet account to get the Aptos client for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n *\n * @returns A promise that resolves to an AptosClient instance\n * @throws NotAptosProviderError If the wallet account's provider is not an APTOS provider\n * @notInstrumented\n */\nexport const getAptosClient = async (\n { walletAccount }: GetAptosClientParams,\n client = getDefaultClient()\n): Promise<AptosClient> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isAptosWalletProvider(provider)) {\n throw new NotAptosProviderError({ providerKey: provider.key });\n }\n\n return provider.getAptosClient({ walletAccount });\n};\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { AptosNetworkProvider } from '../AptosNetworkProvider.types';\n\n/** @notInstrumented */\nexport const isAptosNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is AptosNetworkProvider => networkProvider.chain === 'APTOS';\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosWalletAccount } from '../AptosWalletAccount.types';\nimport type { AptosTransactionPayload } from '../AptosWalletProvider.types';\nimport { NotAptosProviderError } from '../errors/NotAptosProviderError';\nimport { isAptosWalletProvider } from '../isAptosWalletProvider';\n\ntype SignAndSubmitTransactionParams = {\n transaction: AptosTransactionPayload;\n walletAccount: AptosWalletAccount;\n};\n\n/**\n * Signs and submits an Aptos transaction\n *\n * @param params.transaction - The transaction payload to sign and submit\n * @param params.walletAccount - The wallet account to sign the transaction with\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n *\n * @returns An object containing the transaction hash\n * @notInstrumented\n */\nexport const signAndSubmitTransaction = async (\n { transaction, walletAccount }: SignAndSubmitTransactionParams,\n client = getDefaultClient()\n): Promise<{ hash: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isAptosWalletProvider(provider)) {\n throw new NotAptosProviderError({ providerKey: provider.key });\n }\n\n return provider.signAndSubmitTransaction({ transaction, walletAccount });\n};\n","import type { AnyRawTransaction } from '@aptos-labs/ts-sdk';\nimport { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosWalletAccount } from '../AptosWalletAccount.types';\nimport type { AptosSignTransactionOutput } from '../AptosWalletProvider.types';\nimport { NotAptosProviderError } from '../errors/NotAptosProviderError';\nimport { isAptosWalletProvider } from '../isAptosWalletProvider';\n\ntype SignTransactionParams = {\n asFeePayer?: boolean;\n transaction: AnyRawTransaction;\n walletAccount: AptosWalletAccount;\n};\n\n/**\n * Signs an Aptos transaction\n * @param params.transaction - The transaction to sign\n * @param params.walletAccount - The wallet account to sign the transaction with\n * @param params.asFeePayer - Whether to sign as the fee payer\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n *\n * @returns An object containing the signature output\n * @notInstrumented\n */\nexport const signTransaction = async (\n { asFeePayer, transaction, walletAccount }: SignTransactionParams,\n client = getDefaultClient()\n): Promise<{ signature: AptosSignTransactionOutput }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isAptosWalletProvider(provider)) {\n throw new NotAptosProviderError({ providerKey: provider.key });\n }\n\n return provider.signTransaction({ asFeePayer, transaction, walletAccount });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addAptosExtension } from '../addAptosExtension';\nexport type { AptosNetworkProvider } from '../AptosNetworkProvider.types';\nexport type { AptosWalletAccount } from '../AptosWalletAccount.types';\nexport type {\n AptosClient,\n AptosSignTransactionOutput,\n AptosTransaction,\n AptosTransactionPayload,\n} from '../AptosWalletProvider.types';\nexport { NotAptosProviderError } from '../errors/NotAptosProviderError';\nexport { getAptosClient } from '../getAptosClient';\nexport { isAptosNetworkProvider } from '../isAptosNetworkProvider';\nexport { isAptosWalletAccount } from '../isAptosWalletAccount';\nexport { isAptosWalletProvider } from '../isAptosWalletProvider';\nexport { signAndSubmitTransaction } from '../signAndSubmitTransaction';\nexport { signTransaction } from '../signTransaction';\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAa,qBAAqB,8DAA2B,KAAW;AACtE,yEAAgC,OAAO;;;;;;;;;;;;;;;ACUzC,MAAa,iBAAiB,OAC5B,EAAE,iBACF,8DAA2B,KACF;CACzB,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACA,8DAAsB,SAAS,CAClC,OAAM,IAAIC,8DAAsB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGhE,QAAO,SAAS,eAAe,EAAE,eAAe,CAAC;;;;;;AClCnD,MAAa,0BACX,oBAC4C,gBAAgB,UAAU;;;;;;;;;;;;;;ACgBxE,MAAa,2BAA2B,OACtC,EAAE,aAAa,iBACf,yDAA2B,KACG;CAC9B,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,8DAAsB,SAAS,CAClC,OAAM,IAAIC,8DAAsB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGhE,QAAO,SAAS,yBAAyB;EAAE;EAAa;EAAe,CAAC;;;;;;;;;;;;;;;ACb1E,MAAa,kBAAkB,OAC7B,EAAE,YAAY,aAAa,iBAC3B,yDAA2B,KAC4B;CACvD,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,8DAAsB,SAAS,CAClC,OAAM,IAAIC,8DAAsB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGhE,QAAO,SAAS,gBAAgB;EAAE;EAAY;EAAa;EAAe,CAAC;;;;;mEClCxDC,8CAAaC,gDAAe"}
1
+ {"version":3,"file":"index.cjs","names":["isAptosWalletProvider","NotAptosProviderError","isAptosWalletProvider","NotAptosProviderError","isAptosWalletProvider","NotAptosProviderError","packageName","packageVersion"],"sources":["../src/addAptosExtension/addAptosExtension.ts","../src/getAptosClient/getAptosClient.ts","../src/isAptosNetworkProvider/isAptosNetworkProvider.ts","../src/signAndSubmitTransaction/signAndSubmitTransaction.ts","../src/signTransaction/signTransaction.ts","../src/exports/index.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client/core';\n\nimport { addAptosWalletStandardExtension } from '../walletStandard/addAptosWalletStandardExtension';\n\n/**\n * Adds the Aptos extension to the Dynamic client.\n *\n * This is a convenience function that adds support for all of Aptos wallets that support the Aptos Wallet Standard,\n * like Petra, Backpack, OKX, Nightly, and more.\n *\n * @example\n * ```ts\n * const client = createDynamicClient({ environmentId: 'env-123' });\n * addAptosExtension(client);\n * ```\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns void\n * @see isAptosWalletAccount\n * @see isAptosNetworkProvider\n * @notInstrumented\n */\nexport const addAptosExtension = (client = getDefaultClient()): void => {\n addAptosWalletStandardExtension(client);\n};\n","import {\n getDefaultClient,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosWalletAccount } from '../AptosWalletAccount.types';\nimport type { AptosClient } from '../AptosWalletProvider.types';\nimport { NotAptosProviderError } from '../errors/NotAptosProviderError';\nimport { isAptosWalletProvider } from '../isAptosWalletProvider';\n\ntype GetAptosClientParams = {\n walletAccount: AptosWalletAccount;\n};\n\n/**\n * Retrieves an Aptos client from a wallet account.\n *\n * @example\n * ```ts\n * const aptosClient = await getAptosClient({ walletAccount: aptosAccount });\n * ```\n *\n * @param params.walletAccount - The wallet account to get the Aptos client for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to an AptosClient instance.\n * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.\n * @see signAndSubmitTransaction\n * @see isAptosWalletAccount\n * @notInstrumented\n */\nexport const getAptosClient = async (\n { walletAccount }: GetAptosClientParams,\n client = getDefaultClient()\n): Promise<AptosClient> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isAptosWalletProvider(provider)) {\n throw new NotAptosProviderError({ providerKey: provider.key });\n }\n\n return provider.getAptosClient({ walletAccount });\n};\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { AptosNetworkProvider } from '../AptosNetworkProvider.types';\n\n/**\n * Type guard function to check if a network provider is an Aptos network provider.\n *\n * @example\n * ```ts\n * if (isAptosNetworkProvider(networkProvider)) {\n * const aptosClient = networkProvider.getAptosClient();\n * }\n * ```\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is an Aptos network provider, false otherwise.\n * @see isAptosWalletAccount\n * @see addAptosExtension\n * @notInstrumented\n */\nexport const isAptosNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is AptosNetworkProvider => networkProvider.chain === 'APTOS';\n","import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosWalletAccount } from '../AptosWalletAccount.types';\nimport type { AptosTransactionPayload } from '../AptosWalletProvider.types';\nimport { NotAptosProviderError } from '../errors/NotAptosProviderError';\nimport { isAptosWalletProvider } from '../isAptosWalletProvider';\n\ntype SignAndSubmitTransactionParams = {\n transaction: AptosTransactionPayload;\n walletAccount: AptosWalletAccount;\n};\n\n/**\n * Signs and submits an Aptos transaction.\n *\n * @example\n * ```ts\n * const { hash } = await signAndSubmitTransaction({\n * walletAccount: aptosAccount,\n * transaction: { function: '0x1::coin::transfer', arguments: ['0x...', 1000] },\n * });\n * ```\n *\n * @param params.transaction - The transaction payload to sign and submit.\n * @param params.walletAccount - The wallet account to sign the transaction with.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the transaction hash.\n * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.\n * @see signTransaction\n * @see getAptosClient\n * @notInstrumented\n */\nexport const signAndSubmitTransaction = async (\n { transaction, walletAccount }: SignAndSubmitTransactionParams,\n client = getDefaultClient()\n): Promise<{ hash: string }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isAptosWalletProvider(provider)) {\n throw new NotAptosProviderError({ providerKey: provider.key });\n }\n\n return provider.signAndSubmitTransaction({ transaction, walletAccount });\n};\n","import type { AnyRawTransaction } from '@aptos-labs/ts-sdk';\nimport { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport { getWalletProviderFromWalletAccount } from '@dynamic-labs-sdk/client/core';\n\nimport type { AptosWalletAccount } from '../AptosWalletAccount.types';\nimport type { AptosSignTransactionOutput } from '../AptosWalletProvider.types';\nimport { NotAptosProviderError } from '../errors/NotAptosProviderError';\nimport { isAptosWalletProvider } from '../isAptosWalletProvider';\n\ntype SignTransactionParams = {\n asFeePayer?: boolean;\n transaction: AnyRawTransaction;\n walletAccount: AptosWalletAccount;\n};\n\n/**\n * Signs an Aptos transaction without submitting it.\n *\n * @example\n * ```ts\n * const { signature } = await signTransaction({\n * walletAccount: aptosAccount,\n * transaction: aptosTransaction,\n * });\n * ```\n *\n * @param params.transaction - The transaction to sign.\n * @param params.walletAccount - The wallet account to sign the transaction with.\n * @param [params.asFeePayer] - Whether to sign as the fee payer.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An object containing the signature output.\n * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.\n * @see signAndSubmitTransaction\n * @see getAptosClient\n * @notInstrumented\n */\nexport const signTransaction = async (\n { asFeePayer, transaction, walletAccount }: SignTransactionParams,\n client = getDefaultClient()\n): Promise<{ signature: AptosSignTransactionOutput }> => {\n const provider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n if (!isAptosWalletProvider(provider)) {\n throw new NotAptosProviderError({ providerKey: provider.key });\n }\n\n return provider.signTransaction({ asFeePayer, transaction, walletAccount });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addAptosExtension } from '../addAptosExtension';\nexport type { AptosNetworkProvider } from '../AptosNetworkProvider.types';\nexport type { AptosWalletAccount } from '../AptosWalletAccount.types';\nexport type {\n AptosClient,\n AptosSignTransactionOutput,\n AptosTransaction,\n AptosTransactionPayload,\n} from '../AptosWalletProvider.types';\nexport { NotAptosProviderError } from '../errors/NotAptosProviderError';\nexport { getAptosClient } from '../getAptosClient';\nexport { isAptosNetworkProvider } from '../isAptosNetworkProvider';\nexport { isAptosWalletAccount } from '../isAptosWalletAccount';\nexport { isAptosWalletProvider } from '../isAptosWalletProvider';\nexport { signAndSubmitTransaction } from '../signAndSubmitTransaction';\nexport { signTransaction } from '../signTransaction';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,qBAAqB,8DAA2B,KAAW;AACtE,yEAAgC,OAAO;;;;;;;;;;;;;;;;;;;;;ACOzC,MAAa,iBAAiB,OAC5B,EAAE,iBACF,8DAA2B,KACF;CACzB,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACA,8DAAsB,SAAS,CAClC,OAAM,IAAIC,8DAAsB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGhE,QAAO,SAAS,eAAe,EAAE,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;ACzBnD,MAAa,0BACX,oBAC4C,gBAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;ACWxE,MAAa,2BAA2B,OACtC,EAAE,aAAa,iBACf,yDAA2B,KACG;CAC9B,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,8DAAsB,SAAS,CAClC,OAAM,IAAIC,8DAAsB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGhE,QAAO,SAAS,yBAAyB;EAAE;EAAa;EAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;ACZ1E,MAAa,kBAAkB,OAC7B,EAAE,YAAY,aAAa,iBAC3B,yDAA2B,KAC4B;CACvD,MAAM,iFACJ,EACE,eACD,EACD,OACD;AAED,KAAI,CAACC,8DAAsB,SAAS,CAClC,OAAM,IAAIC,8DAAsB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGhE,QAAO,SAAS,gBAAgB;EAAE;EAAY;EAAa;EAAe,CAAC;;;;;mEC7CxDC,8CAAaC,gDAAe"}
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as name, i as NotAptosProviderError, n as isAptosWalletProvider, o as version, r as isAptosWalletAccount, t as addAptosWalletStandardExtension } from "./addAptosWalletStandardExtension-jiIkABI0.esm.js";
1
+ import { a as name, i as NotAptosProviderError, n as isAptosWalletProvider, o as version, r as isAptosWalletAccount, t as addAptosWalletStandardExtension } from "./addAptosWalletStandardExtension-Drme8SEO.esm.js";
2
2
  import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
3
3
  import { getDefaultClient, getWalletProviderFromWalletAccount } from "@dynamic-labs-sdk/client/core";
4
4
  import { getDefaultClient as getDefaultClient$1 } from "@dynamic-labs-sdk/client";
@@ -10,7 +10,16 @@ import { getDefaultClient as getDefaultClient$1 } from "@dynamic-labs-sdk/client
10
10
  * This is a convenience function that adds support for all of Aptos wallets that support the Aptos Wallet Standard,
11
11
  * like Petra, Backpack, OKX, Nightly, and more.
12
12
  *
13
+ * @example
14
+ * ```ts
15
+ * const client = createDynamicClient({ environmentId: 'env-123' });
16
+ * addAptosExtension(client);
17
+ * ```
18
+ *
13
19
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
20
+ * @returns void
21
+ * @see isAptosWalletAccount
22
+ * @see isAptosNetworkProvider
14
23
  * @notInstrumented
15
24
  */
16
25
  const addAptosExtension = (client = getDefaultClient()) => {
@@ -22,11 +31,17 @@ const addAptosExtension = (client = getDefaultClient()) => {
22
31
  /**
23
32
  * Retrieves an Aptos client from a wallet account.
24
33
  *
34
+ * @example
35
+ * ```ts
36
+ * const aptosClient = await getAptosClient({ walletAccount: aptosAccount });
37
+ * ```
38
+ *
25
39
  * @param params.walletAccount - The wallet account to get the Aptos client for.
26
40
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
27
- *
28
- * @returns A promise that resolves to an AptosClient instance
29
- * @throws NotAptosProviderError If the wallet account's provider is not an APTOS provider
41
+ * @returns A promise that resolves to an AptosClient instance.
42
+ * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.
43
+ * @see signAndSubmitTransaction
44
+ * @see isAptosWalletAccount
30
45
  * @notInstrumented
31
46
  */
32
47
  const getAptosClient = async ({ walletAccount }, client = getDefaultClient()) => {
@@ -37,19 +52,44 @@ const getAptosClient = async ({ walletAccount }, client = getDefaultClient()) =>
37
52
 
38
53
  //#endregion
39
54
  //#region src/isAptosNetworkProvider/isAptosNetworkProvider.ts
40
- /** @notInstrumented */
55
+ /**
56
+ * Type guard function to check if a network provider is an Aptos network provider.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * if (isAptosNetworkProvider(networkProvider)) {
61
+ * const aptosClient = networkProvider.getAptosClient();
62
+ * }
63
+ * ```
64
+ *
65
+ * @param networkProvider - The network provider to check.
66
+ * @returns True if the network provider is an Aptos network provider, false otherwise.
67
+ * @see isAptosWalletAccount
68
+ * @see addAptosExtension
69
+ * @notInstrumented
70
+ */
41
71
  const isAptosNetworkProvider = (networkProvider) => networkProvider.chain === "APTOS";
42
72
 
43
73
  //#endregion
44
74
  //#region src/signAndSubmitTransaction/signAndSubmitTransaction.ts
45
75
  /**
46
- * Signs and submits an Aptos transaction
76
+ * Signs and submits an Aptos transaction.
47
77
  *
48
- * @param params.transaction - The transaction payload to sign and submit
49
- * @param params.walletAccount - The wallet account to sign the transaction with
50
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
78
+ * @example
79
+ * ```ts
80
+ * const { hash } = await signAndSubmitTransaction({
81
+ * walletAccount: aptosAccount,
82
+ * transaction: { function: '0x1::coin::transfer', arguments: ['0x...', 1000] },
83
+ * });
84
+ * ```
51
85
  *
52
- * @returns An object containing the transaction hash
86
+ * @param params.transaction - The transaction payload to sign and submit.
87
+ * @param params.walletAccount - The wallet account to sign the transaction with.
88
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
89
+ * @returns An object containing the transaction hash.
90
+ * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.
91
+ * @see signTransaction
92
+ * @see getAptosClient
53
93
  * @notInstrumented
54
94
  */
55
95
  const signAndSubmitTransaction = async ({ transaction, walletAccount }, client = getDefaultClient$1()) => {
@@ -64,13 +104,24 @@ const signAndSubmitTransaction = async ({ transaction, walletAccount }, client =
64
104
  //#endregion
65
105
  //#region src/signTransaction/signTransaction.ts
66
106
  /**
67
- * Signs an Aptos transaction
68
- * @param params.transaction - The transaction to sign
69
- * @param params.walletAccount - The wallet account to sign the transaction with
70
- * @param params.asFeePayer - Whether to sign as the fee payer
71
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
107
+ * Signs an Aptos transaction without submitting it.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const { signature } = await signTransaction({
112
+ * walletAccount: aptosAccount,
113
+ * transaction: aptosTransaction,
114
+ * });
115
+ * ```
72
116
  *
73
- * @returns An object containing the signature output
117
+ * @param params.transaction - The transaction to sign.
118
+ * @param params.walletAccount - The wallet account to sign the transaction with.
119
+ * @param [params.asFeePayer] - Whether to sign as the fee payer.
120
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
121
+ * @returns An object containing the signature output.
122
+ * @throws {NotAptosProviderError} If the wallet account's provider is not an APTOS provider.
123
+ * @see signAndSubmitTransaction
124
+ * @see getAptosClient
74
125
  * @notInstrumented
75
126
  */
76
127
  const signTransaction = async ({ asFeePayer, transaction, walletAccount }, client = getDefaultClient$1()) => {