@dynamic-labs-sdk/aptos 0.17.3 → 0.18.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.
- package/dist/addAptosExtension/addAptosExtension.d.ts +1 -0
- package/dist/addAptosExtension/addAptosExtension.d.ts.map +1 -1
- package/dist/{addAptosWalletStandardExtension-CLi3mOTC.cjs.js → addAptosWalletStandardExtension-alPj3ff7.cjs.js} +12 -2
- package/dist/addAptosWalletStandardExtension-alPj3ff7.cjs.js.map +1 -0
- package/dist/{addAptosWalletStandardExtension-DcIUV_fN.esm.js → addAptosWalletStandardExtension-zoGWMRoc.esm.js} +12 -2
- package/dist/addAptosWalletStandardExtension-zoGWMRoc.esm.js.map +1 -0
- package/dist/getAptosClient/getAptosClient.d.ts +1 -0
- package/dist/getAptosClient/getAptosClient.d.ts.map +1 -1
- package/dist/index.cjs.js +6 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +6 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/isAptosNetworkProvider/isAptosNetworkProvider.d.ts +1 -0
- package/dist/isAptosNetworkProvider/isAptosNetworkProvider.d.ts.map +1 -1
- package/dist/isAptosWalletAccount/isAptosWalletAccount.d.ts +1 -0
- package/dist/isAptosWalletAccount/isAptosWalletAccount.d.ts.map +1 -1
- package/dist/isAptosWalletProvider/isAptosWalletProvider.d.ts +1 -0
- package/dist/isAptosWalletProvider/isAptosWalletProvider.d.ts.map +1 -1
- package/dist/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.d.ts +1 -0
- package/dist/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.d.ts.map +1 -1
- package/dist/signAndSubmitTransaction/signAndSubmitTransaction.d.ts +1 -0
- package/dist/signAndSubmitTransaction/signAndSubmitTransaction.d.ts.map +1 -1
- package/dist/signTransaction/signTransaction.d.ts +1 -0
- package/dist/signTransaction/signTransaction.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/aptosTransferAmount/aptosTransferAmount.d.ts +1 -0
- package/dist/utils/aptosTransferAmount/aptosTransferAmount.d.ts.map +1 -1
- package/dist/utils/createAptosNetworkProvider/createAptosNetworkProvider.d.ts +1 -0
- package/dist/utils/createAptosNetworkProvider/createAptosNetworkProvider.d.ts.map +1 -1
- package/dist/utils/fetchAptosBalance/fetchAptosBalance.d.ts +1 -0
- package/dist/utils/fetchAptosBalance/fetchAptosBalance.d.ts.map +1 -1
- package/dist/walletStandard/addAptosWalletStandardExtension/addAptosWalletStandardExtension.d.ts +1 -0
- package/dist/walletStandard/addAptosWalletStandardExtension/addAptosWalletStandardExtension.d.ts.map +1 -1
- package/dist/walletStandard/utils/createWalletProviderFromAptosStandardWallet/createWalletProviderFromAptosStandardWallet.d.ts +1 -0
- package/dist/walletStandard/utils/createWalletProviderFromAptosStandardWallet/createWalletProviderFromAptosStandardWallet.d.ts.map +1 -1
- package/dist/walletStandard/utils/hasAllRequiredFeatures/hasAllRequiredFeatures.d.ts +1 -0
- package/dist/walletStandard/utils/hasAllRequiredFeatures/hasAllRequiredFeatures.d.ts.map +1 -1
- package/dist/walletStandard/utils/registerAptosStandardWallet/registerAptosStandardWallet.d.ts +1 -0
- package/dist/walletStandard/utils/registerAptosStandardWallet/registerAptosStandardWallet.d.ts.map +1 -1
- package/dist/walletStandard.cjs.js +1 -1
- package/dist/walletStandard.esm.js +1 -1
- package/package.json +4 -4
- package/dist/addAptosWalletStandardExtension-CLi3mOTC.cjs.js.map +0 -1
- package/dist/addAptosWalletStandardExtension-DcIUV_fN.esm.js.map +0 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* like Petra, Backpack, OKX, Nightly, and more.
|
|
6
6
|
*
|
|
7
7
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
8
|
+
* @not-instrumented
|
|
8
9
|
*/
|
|
9
10
|
export declare const addAptosExtension: (client?: import("@dynamic-labs-sdk/client").DynamicClient) => void;
|
|
10
11
|
//# sourceMappingURL=addAptosExtension.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addAptosExtension.d.ts","sourceRoot":"","sources":["../../src/addAptosExtension/addAptosExtension.ts"],"names":[],"mappings":"AAIA
|
|
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"}
|
|
@@ -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 = "0.
|
|
9
|
+
var version = "0.18.0";
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/utils/constants.ts
|
|
@@ -14,6 +14,7 @@ const OCTAS_PER_APT = 1e8;
|
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/utils/fetchAptosBalance/fetchAptosBalance.ts
|
|
17
|
+
/** @not-instrumented */
|
|
17
18
|
const fetchAptosBalance = async ({ address, networkData }) => {
|
|
18
19
|
const balance = await new _aptos_labs_ts_sdk.Aptos(new _aptos_labs_ts_sdk.AptosConfig({
|
|
19
20
|
fullnode: networkData.rpcUrls.http[0],
|
|
@@ -27,6 +28,7 @@ const fetchAptosBalance = async ({ address, networkData }) => {
|
|
|
27
28
|
|
|
28
29
|
//#endregion
|
|
29
30
|
//#region src/utils/createAptosNetworkProvider/createAptosNetworkProvider.ts
|
|
31
|
+
/** @not-instrumented */
|
|
30
32
|
const createAptosNetworkProvider = (networkData) => ({
|
|
31
33
|
...(0, _dynamic_labs_sdk_client_core.createBaseNetworkProvider)("APTOS", networkData),
|
|
32
34
|
cluster: networkData.cluster,
|
|
@@ -38,6 +40,7 @@ const createAptosNetworkProvider = (networkData) => ({
|
|
|
38
40
|
|
|
39
41
|
//#endregion
|
|
40
42
|
//#region src/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.ts
|
|
43
|
+
/** @not-instrumented */
|
|
41
44
|
const registerAptosNetworkProviderBuilder = (client) => {
|
|
42
45
|
const networkProviderBuilderRegistry = (0, _dynamic_labs_sdk_client_core.getNetworkProviderBuilderRegistry)(client);
|
|
43
46
|
if (networkProviderBuilderRegistry.get().get("APTOS")) return;
|
|
@@ -65,10 +68,12 @@ var NotAptosProviderError = class extends _dynamic_labs_sdk_client.BaseError {
|
|
|
65
68
|
|
|
66
69
|
//#endregion
|
|
67
70
|
//#region src/isAptosWalletAccount/isAptosWalletAccount.ts
|
|
71
|
+
/** @not-instrumented */
|
|
68
72
|
const isAptosWalletAccount = (walletAccount) => walletAccount.chain === "APTOS";
|
|
69
73
|
|
|
70
74
|
//#endregion
|
|
71
75
|
//#region src/isAptosWalletProvider/isAptosWalletProvider.ts
|
|
76
|
+
/** @not-instrumented */
|
|
72
77
|
const isAptosWalletProvider = (provider) => {
|
|
73
78
|
return provider.chain === "APTOS";
|
|
74
79
|
};
|
|
@@ -82,6 +87,7 @@ const APT_DECIMALS = 8;
|
|
|
82
87
|
* Converts the human-readable amount string to the smallest unit (octas for APT,
|
|
83
88
|
* or the appropriate unit for fungible tokens) using string-based arithmetic
|
|
84
89
|
* to avoid floating-point precision issues.
|
|
90
|
+
* @not-instrumented
|
|
85
91
|
*/
|
|
86
92
|
const aptosTransferAmount = async ({ amount, recipient, token, walletAccount }, client) => {
|
|
87
93
|
if (!isAptosWalletAccount(walletAccount)) throw new _dynamic_labs_sdk_client.InvalidParamError("Wallet account is not an Aptos wallet account");
|
|
@@ -114,6 +120,7 @@ const aptosTransferAmount = async ({ amount, recipient, token, walletAccount },
|
|
|
114
120
|
|
|
115
121
|
//#endregion
|
|
116
122
|
//#region src/walletStandard/utils/createWalletProviderFromAptosStandardWallet/createWalletProviderFromAptosStandardWallet.ts
|
|
123
|
+
/** @not-instrumented */
|
|
117
124
|
const createWalletProviderFromAptosStandardWallet = ({ dynamicClient, walletStandardWallet }) => {
|
|
118
125
|
const features = walletStandardWallet.features;
|
|
119
126
|
const walletProviderType = _dynamic_labs_sdk_api_core.WalletProviderEnum.BrowserExtension;
|
|
@@ -269,12 +276,14 @@ const REQUIRED_FEATURES = [
|
|
|
269
276
|
"aptos:signMessage",
|
|
270
277
|
"aptos:signTransaction"
|
|
271
278
|
];
|
|
279
|
+
/** @not-instrumented */
|
|
272
280
|
const hasAllRequiredFeatures = (wallet) => {
|
|
273
281
|
return Boolean(REQUIRED_FEATURES.every((feature) => feature in wallet.features));
|
|
274
282
|
};
|
|
275
283
|
|
|
276
284
|
//#endregion
|
|
277
285
|
//#region src/walletStandard/utils/registerAptosStandardWallet/registerAptosStandardWallet.ts
|
|
286
|
+
/** @not-instrumented */
|
|
278
287
|
const registerAptosStandardWallet = (wallet, client) => {
|
|
279
288
|
const walletProviderRegistry = (0, _dynamic_labs_sdk_client_core.getWalletProviderRegistry)(client);
|
|
280
289
|
if (hasAllRequiredFeatures(wallet)) {
|
|
@@ -301,6 +310,7 @@ const APTOS_WALLET_STANDARD_EXTENSION_KEY = "aptosWalletStandard";
|
|
|
301
310
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
302
311
|
*
|
|
303
312
|
* @returns A function that can be used to remove Aptos Wallet Standard register event listener that was added.
|
|
313
|
+
* @not-instrumented
|
|
304
314
|
*/
|
|
305
315
|
const addAptosWalletStandardExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
306
316
|
if ((0, _dynamic_labs_sdk_client_core.hasExtension)({ extensionKey: APTOS_WALLET_STANDARD_EXTENSION_KEY }, client)) return () => {};
|
|
@@ -351,4 +361,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
351
361
|
return version;
|
|
352
362
|
}
|
|
353
363
|
});
|
|
354
|
-
//# sourceMappingURL=addAptosWalletStandardExtension-
|
|
364
|
+
//# sourceMappingURL=addAptosWalletStandardExtension-alPj3ff7.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addAptosWalletStandardExtension-alPj3ff7.cjs.js","names":["Aptos","AptosConfig","BaseError","InvalidParamError","transaction: AptosTransactionPayload","features: AptosFeatures","WalletProviderEnum","connect: AptosWalletProvider['connect']","UserResponseStatus","UserRejectedError","disconnect: AptosWalletProvider['disconnect']","getActiveNetworkId: AptosWalletProvider['getActiveNetworkId']","getAptosClient: AptosWalletProvider['getAptosClient']","Aptos","AptosConfig","getConnectedAddresses: AptosWalletProvider['getConnectedAddresses']","signTransaction: AptosWalletProvider['signTransaction']","signAndSubmitTransaction: AptosWalletProvider['signAndSubmitTransaction']","signMessage: AptosWalletProvider['signMessage']","publicKey: string | undefined","terminate: AptosWalletProvider['terminate']","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/** @not-instrumented */\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/** @not-instrumented */\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/** @not-instrumented */\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/** @not-instrumented */\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/** @not-instrumented */\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 * @not-instrumented\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} 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/** @not-instrumented */\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 disconnect: AptosWalletProvider['disconnect'] = async () => {\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 return disconnectMethod();\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 terminate: AptosWalletProvider['terminate'] = async () => {\n cleanupEventEmitter();\n };\n\n const walletProvider: AptosWalletProvider = {\n chain: 'APTOS',\n connect,\n disconnect,\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 terminate,\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/** @not-instrumented */\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/** @not-instrumented */\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 * @not-instrumented\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,IAAI,QAAQ,CACnD;AAGF,gCAA+B,SAAS;EACtC,SAAS;EACT,OAAO;EACR,CAAC;;;;;AClBJ,IAAa,wBAAb,cAA2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I,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 = "0.
|
|
9
|
+
var version = "0.18.0";
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/utils/constants.ts
|
|
@@ -14,6 +14,7 @@ const OCTAS_PER_APT = 1e8;
|
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/utils/fetchAptosBalance/fetchAptosBalance.ts
|
|
17
|
+
/** @not-instrumented */
|
|
17
18
|
const fetchAptosBalance = async ({ address, networkData }) => {
|
|
18
19
|
const balance = await new Aptos(new AptosConfig({
|
|
19
20
|
fullnode: networkData.rpcUrls.http[0],
|
|
@@ -27,6 +28,7 @@ const fetchAptosBalance = async ({ address, networkData }) => {
|
|
|
27
28
|
|
|
28
29
|
//#endregion
|
|
29
30
|
//#region src/utils/createAptosNetworkProvider/createAptosNetworkProvider.ts
|
|
31
|
+
/** @not-instrumented */
|
|
30
32
|
const createAptosNetworkProvider = (networkData) => ({
|
|
31
33
|
...createBaseNetworkProvider("APTOS", networkData),
|
|
32
34
|
cluster: networkData.cluster,
|
|
@@ -38,6 +40,7 @@ const createAptosNetworkProvider = (networkData) => ({
|
|
|
38
40
|
|
|
39
41
|
//#endregion
|
|
40
42
|
//#region src/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.ts
|
|
43
|
+
/** @not-instrumented */
|
|
41
44
|
const registerAptosNetworkProviderBuilder = (client) => {
|
|
42
45
|
const networkProviderBuilderRegistry = getNetworkProviderBuilderRegistry(client);
|
|
43
46
|
if (networkProviderBuilderRegistry.get().get("APTOS")) return;
|
|
@@ -65,10 +68,12 @@ var NotAptosProviderError = class extends BaseError {
|
|
|
65
68
|
|
|
66
69
|
//#endregion
|
|
67
70
|
//#region src/isAptosWalletAccount/isAptosWalletAccount.ts
|
|
71
|
+
/** @not-instrumented */
|
|
68
72
|
const isAptosWalletAccount = (walletAccount) => walletAccount.chain === "APTOS";
|
|
69
73
|
|
|
70
74
|
//#endregion
|
|
71
75
|
//#region src/isAptosWalletProvider/isAptosWalletProvider.ts
|
|
76
|
+
/** @not-instrumented */
|
|
72
77
|
const isAptosWalletProvider = (provider) => {
|
|
73
78
|
return provider.chain === "APTOS";
|
|
74
79
|
};
|
|
@@ -82,6 +87,7 @@ const APT_DECIMALS = 8;
|
|
|
82
87
|
* Converts the human-readable amount string to the smallest unit (octas for APT,
|
|
83
88
|
* or the appropriate unit for fungible tokens) using string-based arithmetic
|
|
84
89
|
* to avoid floating-point precision issues.
|
|
90
|
+
* @not-instrumented
|
|
85
91
|
*/
|
|
86
92
|
const aptosTransferAmount = async ({ amount, recipient, token, walletAccount }, client) => {
|
|
87
93
|
if (!isAptosWalletAccount(walletAccount)) throw new InvalidParamError("Wallet account is not an Aptos wallet account");
|
|
@@ -114,6 +120,7 @@ const aptosTransferAmount = async ({ amount, recipient, token, walletAccount },
|
|
|
114
120
|
|
|
115
121
|
//#endregion
|
|
116
122
|
//#region src/walletStandard/utils/createWalletProviderFromAptosStandardWallet/createWalletProviderFromAptosStandardWallet.ts
|
|
123
|
+
/** @not-instrumented */
|
|
117
124
|
const createWalletProviderFromAptosStandardWallet = ({ dynamicClient, walletStandardWallet }) => {
|
|
118
125
|
const features = walletStandardWallet.features;
|
|
119
126
|
const walletProviderType = WalletProviderEnum.BrowserExtension;
|
|
@@ -269,12 +276,14 @@ const REQUIRED_FEATURES = [
|
|
|
269
276
|
"aptos:signMessage",
|
|
270
277
|
"aptos:signTransaction"
|
|
271
278
|
];
|
|
279
|
+
/** @not-instrumented */
|
|
272
280
|
const hasAllRequiredFeatures = (wallet) => {
|
|
273
281
|
return Boolean(REQUIRED_FEATURES.every((feature) => feature in wallet.features));
|
|
274
282
|
};
|
|
275
283
|
|
|
276
284
|
//#endregion
|
|
277
285
|
//#region src/walletStandard/utils/registerAptosStandardWallet/registerAptosStandardWallet.ts
|
|
286
|
+
/** @not-instrumented */
|
|
278
287
|
const registerAptosStandardWallet = (wallet, client) => {
|
|
279
288
|
const walletProviderRegistry = getWalletProviderRegistry(client);
|
|
280
289
|
if (hasAllRequiredFeatures(wallet)) {
|
|
@@ -301,6 +310,7 @@ const APTOS_WALLET_STANDARD_EXTENSION_KEY = "aptosWalletStandard";
|
|
|
301
310
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
302
311
|
*
|
|
303
312
|
* @returns A function that can be used to remove Aptos Wallet Standard register event listener that was added.
|
|
313
|
+
* @not-instrumented
|
|
304
314
|
*/
|
|
305
315
|
const addAptosWalletStandardExtension = (client = getDefaultClient()) => {
|
|
306
316
|
if (hasExtension({ extensionKey: APTOS_WALLET_STANDARD_EXTENSION_KEY }, client)) return () => {};
|
|
@@ -316,4 +326,4 @@ const addAptosWalletStandardExtension = (client = getDefaultClient()) => {
|
|
|
316
326
|
|
|
317
327
|
//#endregion
|
|
318
328
|
export { name as a, NotAptosProviderError as i, isAptosWalletProvider as n, version as o, isAptosWalletAccount as r, addAptosWalletStandardExtension as t };
|
|
319
|
-
//# sourceMappingURL=addAptosWalletStandardExtension-
|
|
329
|
+
//# sourceMappingURL=addAptosWalletStandardExtension-zoGWMRoc.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addAptosWalletStandardExtension-zoGWMRoc.esm.js","names":["transaction: AptosTransactionPayload","features: AptosFeatures","connect: AptosWalletProvider['connect']","disconnect: AptosWalletProvider['disconnect']","getActiveNetworkId: AptosWalletProvider['getActiveNetworkId']","getAptosClient: AptosWalletProvider['getAptosClient']","getConnectedAddresses: AptosWalletProvider['getConnectedAddresses']","signTransaction: AptosWalletProvider['signTransaction']","signAndSubmitTransaction: AptosWalletProvider['signAndSubmitTransaction']","signMessage: AptosWalletProvider['signMessage']","publicKey: string | undefined","terminate: AptosWalletProvider['terminate']","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/** @not-instrumented */\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/** @not-instrumented */\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/** @not-instrumented */\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/** @not-instrumented */\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/** @not-instrumented */\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 * @not-instrumented\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} 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/** @not-instrumented */\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 disconnect: AptosWalletProvider['disconnect'] = async () => {\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 return disconnectMethod();\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 terminate: AptosWalletProvider['terminate'] = async () => {\n cleanupEventEmitter();\n };\n\n const walletProvider: AptosWalletProvider = {\n chain: 'APTOS',\n connect,\n disconnect,\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 terminate,\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/** @not-instrumented */\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/** @not-instrumented */\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 * @not-instrumented\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;A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AO;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"}
|
|
@@ -11,6 +11,7 @@ type GetAptosClientParams = {
|
|
|
11
11
|
*
|
|
12
12
|
* @returns A promise that resolves to an AptosClient instance
|
|
13
13
|
* @throws NotAptosProviderError If the wallet account's provider is not an APTOS provider
|
|
14
|
+
* @not-instrumented
|
|
14
15
|
*/
|
|
15
16
|
export declare const getAptosClient: ({ walletAccount }: GetAptosClientParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<AptosClient>;
|
|
16
17
|
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
|
|
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"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_addAptosWalletStandardExtension = require('./addAptosWalletStandardExtension-
|
|
1
|
+
const require_addAptosWalletStandardExtension = require('./addAptosWalletStandardExtension-alPj3ff7.cjs.js');
|
|
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");
|
|
@@ -11,6 +11,7 @@ let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
|
11
11
|
* like Petra, Backpack, OKX, Nightly, and more.
|
|
12
12
|
*
|
|
13
13
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
14
|
+
* @not-instrumented
|
|
14
15
|
*/
|
|
15
16
|
const addAptosExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
16
17
|
require_addAptosWalletStandardExtension.addAptosWalletStandardExtension(client);
|
|
@@ -26,6 +27,7 @@ const addAptosExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefault
|
|
|
26
27
|
*
|
|
27
28
|
* @returns A promise that resolves to an AptosClient instance
|
|
28
29
|
* @throws NotAptosProviderError If the wallet account's provider is not an APTOS provider
|
|
30
|
+
* @not-instrumented
|
|
29
31
|
*/
|
|
30
32
|
const getAptosClient = async ({ walletAccount }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
31
33
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
@@ -35,6 +37,7 @@ const getAptosClient = async ({ walletAccount }, client = (0, _dynamic_labs_sdk_
|
|
|
35
37
|
|
|
36
38
|
//#endregion
|
|
37
39
|
//#region src/isAptosNetworkProvider/isAptosNetworkProvider.ts
|
|
40
|
+
/** @not-instrumented */
|
|
38
41
|
const isAptosNetworkProvider = (networkProvider) => networkProvider.chain === "APTOS";
|
|
39
42
|
|
|
40
43
|
//#endregion
|
|
@@ -47,6 +50,7 @@ const isAptosNetworkProvider = (networkProvider) => networkProvider.chain === "A
|
|
|
47
50
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
48
51
|
*
|
|
49
52
|
* @returns An object containing the transaction hash
|
|
53
|
+
* @not-instrumented
|
|
50
54
|
*/
|
|
51
55
|
const signAndSubmitTransaction = async ({ transaction, walletAccount }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
52
56
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
@@ -67,6 +71,7 @@ const signAndSubmitTransaction = async ({ transaction, walletAccount }, client =
|
|
|
67
71
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
68
72
|
*
|
|
69
73
|
* @returns An object containing the signature output
|
|
74
|
+
* @not-instrumented
|
|
70
75
|
*/
|
|
71
76
|
const signTransaction = async ({ asFeePayer, transaction, walletAccount }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
72
77
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","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 */\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 */\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\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 */\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 */\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":"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","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 * @not-instrumented\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 * @not-instrumented\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/** @not-instrumented */\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 * @not-instrumented\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 * @not-instrumented\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"}
|
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-
|
|
1
|
+
import { a as name, i as NotAptosProviderError, n as isAptosWalletProvider, o as version, r as isAptosWalletAccount, t as addAptosWalletStandardExtension } from "./addAptosWalletStandardExtension-zoGWMRoc.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";
|
|
@@ -11,6 +11,7 @@ import { getDefaultClient as getDefaultClient$1 } from "@dynamic-labs-sdk/client
|
|
|
11
11
|
* like Petra, Backpack, OKX, Nightly, and more.
|
|
12
12
|
*
|
|
13
13
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
14
|
+
* @not-instrumented
|
|
14
15
|
*/
|
|
15
16
|
const addAptosExtension = (client = getDefaultClient()) => {
|
|
16
17
|
addAptosWalletStandardExtension(client);
|
|
@@ -26,6 +27,7 @@ const addAptosExtension = (client = getDefaultClient()) => {
|
|
|
26
27
|
*
|
|
27
28
|
* @returns A promise that resolves to an AptosClient instance
|
|
28
29
|
* @throws NotAptosProviderError If the wallet account's provider is not an APTOS provider
|
|
30
|
+
* @not-instrumented
|
|
29
31
|
*/
|
|
30
32
|
const getAptosClient = async ({ walletAccount }, client = getDefaultClient()) => {
|
|
31
33
|
const provider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
@@ -35,6 +37,7 @@ const getAptosClient = async ({ walletAccount }, client = getDefaultClient()) =>
|
|
|
35
37
|
|
|
36
38
|
//#endregion
|
|
37
39
|
//#region src/isAptosNetworkProvider/isAptosNetworkProvider.ts
|
|
40
|
+
/** @not-instrumented */
|
|
38
41
|
const isAptosNetworkProvider = (networkProvider) => networkProvider.chain === "APTOS";
|
|
39
42
|
|
|
40
43
|
//#endregion
|
|
@@ -47,6 +50,7 @@ const isAptosNetworkProvider = (networkProvider) => networkProvider.chain === "A
|
|
|
47
50
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
48
51
|
*
|
|
49
52
|
* @returns An object containing the transaction hash
|
|
53
|
+
* @not-instrumented
|
|
50
54
|
*/
|
|
51
55
|
const signAndSubmitTransaction = async ({ transaction, walletAccount }, client = getDefaultClient$1()) => {
|
|
52
56
|
const provider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
@@ -67,6 +71,7 @@ const signAndSubmitTransaction = async ({ transaction, walletAccount }, client =
|
|
|
67
71
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
68
72
|
*
|
|
69
73
|
* @returns An object containing the signature output
|
|
74
|
+
* @not-instrumented
|
|
70
75
|
*/
|
|
71
76
|
const signTransaction = async ({ asFeePayer, transaction, walletAccount }, client = getDefaultClient$1()) => {
|
|
72
77
|
const provider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","names":["getDefaultClient","getDefaultClient","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 */\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 */\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\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 */\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 */\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":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","names":["getDefaultClient","getDefaultClient","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 * @not-instrumented\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 * @not-instrumented\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/** @not-instrumented */\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 * @not-instrumented\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 * @not-instrumented\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,SAAS,kBAAkB,KAAW;AACtE,iCAAgC,OAAO;;;;;;;;;;;;;;;ACUzC,MAAa,iBAAiB,OAC5B,EAAE,iBACF,SAAS,kBAAkB,KACF;CACzB,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,sBAAsB,SAAS,CAClC,OAAM,IAAI,sBAAsB,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,SAASA,oBAAkB,KACG;CAC9B,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,sBAAsB,SAAS,CAClC,OAAM,IAAI,sBAAsB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGhE,QAAO,SAAS,yBAAyB;EAAE;EAAa;EAAe,CAAC;;;;;;;;;;;;;;;ACb1E,MAAa,kBAAkB,OAC7B,EAAE,YAAY,aAAa,iBAC3B,SAASC,oBAAkB,KAC4B;CACvD,MAAM,WAAW,mCACf,EACE,eACD,EACD,OACD;AAED,KAAI,CAAC,sBAAsB,SAAS,CAClC,OAAM,IAAI,sBAAsB,EAAE,aAAa,SAAS,KAAK,CAAC;AAGhE,QAAO,SAAS,gBAAgB;EAAE;EAAY;EAAa;EAAe,CAAC;;;;;AClC7E,qBAAqBC,MAAaC,QAAe"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NetworkProvider } from '@dynamic-labs-sdk/client';
|
|
2
2
|
import type { AptosNetworkProvider } from '../AptosNetworkProvider.types';
|
|
3
|
+
/** @not-instrumented */
|
|
3
4
|
export declare const isAptosNetworkProvider: (networkProvider: NetworkProvider) => networkProvider is AptosNetworkProvider;
|
|
4
5
|
//# sourceMappingURL=isAptosNetworkProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAptosNetworkProvider.d.ts","sourceRoot":"","sources":["../../src/isAptosNetworkProvider/isAptosNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,eAAO,MAAM,sBAAsB,oBAChB,eAAe,KAC/B,eAAe,IAAI,oBAAyD,CAAC"}
|
|
1
|
+
{"version":3,"file":"isAptosNetworkProvider.d.ts","sourceRoot":"","sources":["../../src/isAptosNetworkProvider/isAptosNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,wBAAwB;AACxB,eAAO,MAAM,sBAAsB,oBAChB,eAAe,KAC/B,eAAe,IAAI,oBAAyD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WalletAccount } from '@dynamic-labs-sdk/client';
|
|
2
2
|
import type { AptosWalletAccount } from '../AptosWalletAccount.types';
|
|
3
|
+
/** @not-instrumented */
|
|
3
4
|
export declare const isAptosWalletAccount: (walletAccount: WalletAccount) => walletAccount is AptosWalletAccount;
|
|
4
5
|
//# sourceMappingURL=isAptosWalletAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAptosWalletAccount.d.ts","sourceRoot":"","sources":["../../src/isAptosWalletAccount/isAptosWalletAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,eAAO,MAAM,oBAAoB,kBAChB,aAAa,KAC3B,aAAa,IAAI,kBAAqD,CAAC"}
|
|
1
|
+
{"version":3,"file":"isAptosWalletAccount.d.ts","sourceRoot":"","sources":["../../src/isAptosWalletAccount/isAptosWalletAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,wBAAwB;AACxB,eAAO,MAAM,oBAAoB,kBAChB,aAAa,KAC3B,aAAa,IAAI,kBAAqD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WalletProvider } from '@dynamic-labs-sdk/client/core';
|
|
2
2
|
import type { AptosWalletProvider } from '../AptosWalletProvider.types';
|
|
3
|
+
/** @not-instrumented */
|
|
3
4
|
export declare const isAptosWalletProvider: (provider: WalletProvider | AptosWalletProvider) => provider is AptosWalletProvider;
|
|
4
5
|
//# sourceMappingURL=isAptosWalletProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAptosWalletProvider.d.ts","sourceRoot":"","sources":["../../src/isAptosWalletProvider/isAptosWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,eAAO,MAAM,qBAAqB,aACtB,cAAc,GAAG,mBAAmB,KAC7C,QAAQ,IAAI,mBAEd,CAAC"}
|
|
1
|
+
{"version":3,"file":"isAptosWalletProvider.d.ts","sourceRoot":"","sources":["../../src/isAptosWalletProvider/isAptosWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,wBAAwB;AACxB,eAAO,MAAM,qBAAqB,aACtB,cAAc,GAAG,mBAAmB,KAC7C,QAAQ,IAAI,mBAEd,CAAC"}
|
package/dist/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerAptosNetworkProviderBuilder.d.ts","sourceRoot":"","sources":["../../src/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,mCAAmC,WACtC,aAAa,KACpB,IAaF,CAAC"}
|
|
1
|
+
{"version":3,"file":"registerAptosNetworkProviderBuilder.d.ts","sourceRoot":"","sources":["../../src/registerAptosNetworkProviderBuilder/registerAptosNetworkProviderBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,wBAAwB;AACxB,eAAO,MAAM,mCAAmC,WACtC,aAAa,KACpB,IAaF,CAAC"}
|
|
@@ -12,6 +12,7 @@ type SignAndSubmitTransactionParams = {
|
|
|
12
12
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
13
13
|
*
|
|
14
14
|
* @returns An object containing the transaction hash
|
|
15
|
+
* @not-instrumented
|
|
15
16
|
*/
|
|
16
17
|
export declare const signAndSubmitTransaction: ({ transaction, walletAccount }: SignAndSubmitTransactionParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<{
|
|
17
18
|
hash: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signAndSubmitTransaction.d.ts","sourceRoot":"","sources":["../../src/signAndSubmitTransaction/signAndSubmitTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAI5E,KAAK,8BAA8B,GAAG;IACpC,WAAW,EAAE,uBAAuB,CAAC;IACrC,aAAa,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"signAndSubmitTransaction.d.ts","sourceRoot":"","sources":["../../src/signAndSubmitTransaction/signAndSubmitTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAI5E,KAAK,8BAA8B,GAAG;IACpC,WAAW,EAAE,uBAAuB,CAAC;IACrC,aAAa,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,mCACH,8BAA8B,gEAE7D,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAa1B,CAAC"}
|
|
@@ -14,6 +14,7 @@ type SignTransactionParams = {
|
|
|
14
14
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
15
15
|
*
|
|
16
16
|
* @returns An object containing the signature output
|
|
17
|
+
* @not-instrumented
|
|
17
18
|
*/
|
|
18
19
|
export declare const signTransaction: ({ asFeePayer, transaction, walletAccount }: SignTransactionParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<{
|
|
19
20
|
signature: AptosSignTransactionOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../src/signTransaction/signTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI/E,KAAK,qBAAqB,GAAG;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,aAAa,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../src/signTransaction/signTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI/E,KAAK,qBAAqB,GAAG;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,aAAa,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,+CACkB,qBAAqB,gEAEhE,OAAO,CAAC;IAAE,SAAS,EAAE,0BAA0B,CAAA;CAAE,CAanD,CAAC"}
|