@aptos-labs/ts-sdk 5.1.1-side-effect-free.0 → 5.1.1-side-effect-free.1

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.
@@ -2,9 +2,9 @@ import { GetAccountOwnedTokensQueryResponse, GetAccountOwnedTokensFromCollection
2
2
  import { A as AptosConfig, m as AccountAddressInput, c9 as AccountData, c6 as LedgerVersionArg, ca as MoveModuleBytecode, bQ as CursorPaginationArgs, bP as PaginationArgs, cc as TransactionResponse, c8 as MoveResource, d8 as MoveStructId, bN as AnyNumber, n as AccountAddress, bR as TokenStandardArg, bS as OrderByArg, bT as WhereArg, L as PrivateKeyInput } from '../account-BortO8g2.mjs';
3
3
  import { CurrentFungibleAssetBalancesBoolExp } from '../types/generated/types.mjs';
4
4
  import { A as Account$1 } from '../Ed25519Account-CPwej6wB.mjs';
5
+ import { AccountAbstraction } from './account/abstraction.mjs';
5
6
  import { BaseAccountPublicKey } from '../core/crypto/types.mjs';
6
7
  import { AccountInfo } from '../internal/account.mjs';
7
- import { AccountAbstraction } from './account/abstraction.mjs';
8
8
  import '../types/generated/operations.mjs';
9
9
  import '../utils/apiEndpoints.mjs';
10
10
  import '../utils/const.mjs';
@@ -11,6 +11,7 @@ import { Transaction } from './transaction.mjs';
11
11
  import { Table } from './table.mjs';
12
12
  import { Keyless } from './keyless.mjs';
13
13
  import { AptosObject } from './object.mjs';
14
+ import { AccountAbstraction } from './account/abstraction.mjs';
14
15
  import '../types/indexer.mjs';
15
16
  import '../types/generated/operations.mjs';
16
17
  import '../types/generated/types.mjs';
@@ -21,7 +22,6 @@ import '../utils/const.mjs';
21
22
  import '../core/common.mjs';
22
23
  import '../internal/account.mjs';
23
24
  import '../account/MultiEd25519Account.mjs';
24
- import './account/abstraction.mjs';
25
25
  import '../internal/digitalAsset.mjs';
26
26
  import '../internal/ans.mjs';
27
27
  import '../internal/transactionSubmission.mjs';
@@ -71,18 +71,20 @@ import '../account/FederatedKeylessAccount.mjs';
71
71
  */
72
72
  declare class Aptos {
73
73
  readonly config: AptosConfig;
74
- readonly account: Account;
75
- readonly ans: ANS;
76
- readonly coin: Coin;
77
- readonly digitalAsset: DigitalAsset;
78
- readonly faucet: Faucet;
79
- readonly fungibleAsset: FungibleAsset;
80
- readonly general: General;
81
- readonly staking: Staking;
82
- readonly transaction: Transaction;
83
- readonly table: Table;
84
- readonly keyless: Keyless;
85
- readonly object: AptosObject;
74
+ private _account?;
75
+ private _abstraction?;
76
+ private _ans?;
77
+ private _coin?;
78
+ private _digitalAsset?;
79
+ private _faucet?;
80
+ private _fungibleAsset?;
81
+ private _general?;
82
+ private _staking?;
83
+ private _transaction?;
84
+ private _table?;
85
+ private _keyless?;
86
+ private _object?;
87
+ static mixinsApplied: Set<string>;
86
88
  /**
87
89
  * Initializes a new instance of the Aptos client with the provided configuration settings.
88
90
  * This allows you to interact with various Aptos functionalities such as accounts, transactions, and events.
@@ -105,9 +107,74 @@ declare class Aptos {
105
107
  * @group Client
106
108
  */
107
109
  constructor(config?: AptosConfig);
110
+ /**
111
+ * Lazy-loaded getter for Account functionality.
112
+ * Only instantiates and applies mixin when first accessed.
113
+ */
114
+ get account(): Account;
115
+ /**
116
+ * Lazy-loaded getter for AccountAbstraction functionality.
117
+ * Only instantiates and applies mixin when first accessed.
118
+ */
119
+ get abstraction(): AccountAbstraction;
120
+ /**
121
+ * Lazy-loaded getter for ANS functionality.
122
+ * Only instantiates and applies mixin when first accessed.
123
+ */
124
+ get ans(): ANS;
125
+ /**
126
+ * Lazy-loaded getter for Coin functionality.
127
+ * Only instantiates and applies mixin when first accessed.
128
+ */
129
+ get coin(): Coin;
130
+ /**
131
+ * Lazy-loaded getter for DigitalAsset functionality.
132
+ * Only instantiates and applies mixin when first accessed.
133
+ */
134
+ get digitalAsset(): DigitalAsset;
135
+ /**
136
+ * Lazy-loaded getter for Faucet functionality.
137
+ * Only instantiates and applies mixin when first accessed.
138
+ */
139
+ get faucet(): Faucet;
140
+ /**
141
+ * Lazy-loaded getter for FungibleAsset functionality.
142
+ * Only instantiates and applies mixin when first accessed.
143
+ */
144
+ get fungibleAsset(): FungibleAsset;
145
+ /**
146
+ * Lazy-loaded getter for General functionality.
147
+ * Only instantiates and applies mixin when first accessed.
148
+ */
149
+ get general(): General;
150
+ /**
151
+ * Lazy-loaded getter for Staking functionality.
152
+ * Only instantiates and applies mixin when first accessed.
153
+ */
154
+ get staking(): Staking;
155
+ /**
156
+ * Lazy-loaded getter for Transaction functionality.
157
+ * Only instantiates and applies mixin when first accessed.
158
+ */
159
+ get transaction(): Transaction;
160
+ /**
161
+ * Lazy-loaded getter for Table functionality.
162
+ * Only instantiates and applies mixin when first accessed.
163
+ */
164
+ get table(): Table;
165
+ /**
166
+ * Lazy-loaded getter for Keyless functionality.
167
+ * Only instantiates and applies mixin when first accessed.
168
+ */
169
+ get keyless(): Keyless;
170
+ /**
171
+ * Lazy-loaded getter for AptosObject functionality.
172
+ * Only instantiates and applies mixin when first accessed.
173
+ */
174
+ get object(): AptosObject;
108
175
  setIgnoreTransactionSubmitter(ignore: boolean): void;
109
176
  }
110
- interface Aptos extends Account, ANS, Coin, DigitalAsset, Event, Faucet, FungibleAsset, General, Keyless, Staking, Table, AptosObject, Omit<Transaction, "build" | "simulate" | "submit" | "batch"> {
177
+ interface Aptos extends Account, AccountAbstraction, ANS, Coin, DigitalAsset, Faucet, FungibleAsset, General, Keyless, Staking, Table, AptosObject, Omit<Transaction, "build" | "simulate" | "submit" | "batch"> {
111
178
  }
112
179
 
113
180
  export { Aptos };
@@ -1,2 +1,2 @@
1
- import{Account as r}from"./account";import{AptosConfig as k}from"./aptosConfig";import{Coin as a}from"./coin";import{DigitalAsset as c}from"./digitalAsset";import{Faucet as l}from"./faucet";import{FungibleAsset as f}from"./fungibleAsset";import{General as g}from"./general";import{ANS as p}from"./ans";import{Staking as u}from"./staking";import{Transaction as b}from"./transaction";import{Table as m}from"./table";import{Keyless as h}from"./keyless";import{AptosObject as A}from"./object";import{AccountAbstraction as y}from"./account/abstraction";class t{constructor(n){O(),this.config=n??new k,this.account=new r(this.config),this.abstraction=new y(this.config),this.ans=new p(this.config),this.coin=new a(this.config),this.digitalAsset=new c(this.config),this.faucet=new l(this.config),this.fungibleAsset=new f(this.config),this.general=new g(this.config),this.staking=new u(this.config),this.transaction=new b(this.config),this.table=new m(this.config),this.keyless=new h(this.config),this.object=new A(this.config)}setIgnoreTransactionSubmitter(n){this.config.setIgnoreTransactionSubmitter(n)}}function e(s,n,w){Object.getOwnPropertyNames(n.prototype).forEach(o=>{const i=Object.getOwnPropertyDescriptor(n.prototype,o);i&&Object.defineProperty(s.prototype,o,{value:function(...j){return this[w][o](...j)},writable:i.writable,configurable:i.configurable,enumerable:i.enumerable})})}let d=!1;function O(){d||(e(t,r,"account"),e(t,y,"abstraction"),e(t,p,"ans"),e(t,a,"coin"),e(t,c,"digitalAsset"),e(t,Event,"event"),e(t,l,"faucet"),e(t,f,"fungibleAsset"),e(t,g,"general"),e(t,u,"staking"),e(t,b,"transaction"),e(t,m,"table"),e(t,h,"keyless"),e(t,A,"object"),d=!0)}export{t as Aptos};
1
+ import{Account as c}from"./account";import{AptosConfig as k}from"./aptosConfig";import{Coin as g}from"./coin";import{DigitalAsset as f}from"./digitalAsset";import{Faucet as u}from"./faucet";import{FungibleAsset as l}from"./fungibleAsset";import{General as h}from"./general";import{ANS as b}from"./ans";import{Staking as p}from"./staking";import{Transaction as A}from"./transaction";import{Table as m}from"./table";import{Keyless as _}from"./keyless";import{AptosObject as y}from"./object";import{AccountAbstraction as w}from"./account/abstraction";const t=class t{constructor(e){this.config=e??new k}get account(){return this._account||(i(t,c,"account"),this._account=new c(this.config)),this._account}get abstraction(){return this._abstraction||(i(t,w,"abstraction"),this._abstraction=new w(this.config)),this._abstraction}get ans(){return this._ans||(i(t,b,"ans"),this._ans=new b(this.config)),this._ans}get coin(){return this._coin||(i(t,g,"coin"),this._coin=new g(this.config)),this._coin}get digitalAsset(){return this._digitalAsset||(i(t,f,"digitalAsset"),this._digitalAsset=new f(this.config)),this._digitalAsset}get faucet(){return this._faucet||(i(t,u,"faucet"),this._faucet=new u(this.config)),this._faucet}get fungibleAsset(){return this._fungibleAsset||(i(t,l,"fungibleAsset"),this._fungibleAsset=new l(this.config)),this._fungibleAsset}get general(){return this._general||(i(t,h,"general"),this._general=new h(this.config)),this._general}get staking(){return this._staking||(i(t,p,"staking"),this._staking=new p(this.config)),this._staking}get transaction(){return this._transaction||(i(t,A,"transaction"),this._transaction=new A(this.config)),this._transaction}get table(){return this._table||(i(t,m,"table"),this._table=new m(this.config)),this._table}get keyless(){return this._keyless||(i(t,_,"keyless"),this._keyless=new _(this.config)),this._keyless}get object(){return this._object||(i(t,y,"object"),this._object=new y(this.config)),this._object}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};t.mixinsApplied=new Set;let a=t;function v(s,e,r){Object.getOwnPropertyNames(e.prototype).forEach(n=>{const o=Object.getOwnPropertyDescriptor(e.prototype,n);o&&(n==="constructor"||s.prototype[n]||Object.defineProperty(s.prototype,n,{value:function(...d){return this[r][n](...d)},writable:o.writable,configurable:o.configurable,enumerable:o.enumerable}))})}function i(s,e,r){const n=`${s.name}-${e.name}-${r}`;a.mixinsApplied.has(n)||(v(s,e,r),a.mixinsApplied.add(n))}export{a as Aptos};
2
2
  //# sourceMappingURL=aptos.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/api/aptos.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"./account\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { Coin } from \"./coin\";\nimport { DigitalAsset } from \"./digitalAsset\";\nimport { Faucet } from \"./faucet\";\nimport { FungibleAsset } from \"./fungibleAsset\";\nimport { General } from \"./general\";\nimport { ANS } from \"./ans\";\nimport { Staking } from \"./staking\";\nimport { Transaction } from \"./transaction\";\nimport { Table } from \"./table\";\nimport { Keyless } from \"./keyless\";\nimport { AptosObject } from \"./object\";\nimport { AccountAbstraction } from \"./account/abstraction\";\n\n/**\n * The main entry point for interacting with the Aptos APIs,\n * providing access to various functionalities organized into\n * distinct namespaces.\n *\n * To utilize the SDK, instantiate a new Aptos object to gain\n * access to the complete range of SDK features.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for connecting to the Aptos testnet\n * const config = new AptosConfig({ network: Network.TESTNET });\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\nexport class Aptos {\n readonly config: AptosConfig;\n\n readonly account: Account;\n\n readonly ans: ANS;\n\n readonly coin: Coin;\n\n readonly digitalAsset: DigitalAsset;\n\n readonly faucet: Faucet;\n\n readonly fungibleAsset: FungibleAsset;\n\n readonly general: General;\n\n readonly staking: Staking;\n\n readonly transaction: Transaction;\n\n readonly table: Table;\n\n readonly keyless: Keyless;\n\n readonly object: AptosObject;\n\n /**\n * Initializes a new instance of the Aptos client with the provided configuration settings.\n * This allows you to interact with various Aptos functionalities such as accounts, transactions, and events.\n *\n * @param settings - Configuration settings for the Aptos client.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a new Aptos client with default settings\n * const config = new AptosConfig({ network: Network.TESTNET }); // Specify your own settings if needed\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n constructor(config?: AptosConfig) {\n ensureMixinsApplied();\n this.config = config ?? new AptosConfig();\n this.account = new Account(this.config);\n this.abstraction = new AccountAbstraction(this.config);\n this.ans = new ANS(this.config);\n this.coin = new Coin(this.config);\n this.digitalAsset = new DigitalAsset(this.config);\n this.faucet = new Faucet(this.config);\n this.fungibleAsset = new FungibleAsset(this.config);\n this.general = new General(this.config);\n this.staking = new Staking(this.config);\n this.transaction = new Transaction(this.config);\n this.table = new Table(this.config);\n this.keyless = new Keyless(this.config);\n this.object = new AptosObject(this.config);\n }\n\n setIgnoreTransactionSubmitter(ignore: boolean) {\n this.config.setIgnoreTransactionSubmitter(ignore);\n }\n}\n\n// extends Aptos interface so all the methods and properties\n// from the other classes will be recognized by typescript.\nexport interface Aptos\n extends Account,\n ANS,\n Coin,\n DigitalAsset,\n Event,\n Faucet,\n FungibleAsset,\n General,\n Keyless,\n Staking,\n Table,\n AptosObject,\n Omit<Transaction, \"build\" | \"simulate\" | \"submit\" | \"batch\"> {}\n\n/**\nIn TypeScript, we can’t inherit or extend from more than one class,\nMixins helps us to get around that by creating a partial classes\nthat we can combine to form a single class that contains all the methods and properties from the partial classes.\n{@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}\n\nHere, we combine any subclass and the Aptos class.\n * @group Client\n*/\nfunction applyMixin(targetClass: any, baseClass: any, baseClassProp: string) {\n // Mixin instance methods\n Object.getOwnPropertyNames(baseClass.prototype).forEach((propertyName) => {\n const propertyDescriptor = Object.getOwnPropertyDescriptor(baseClass.prototype, propertyName);\n if (!propertyDescriptor) return;\n\n // Define new method that calls through baseClassProp\n Object.defineProperty(targetClass.prototype, propertyName, {\n value: function (...args: any[]) {\n return (this as any)[baseClassProp][propertyName](...args);\n },\n writable: propertyDescriptor.writable,\n configurable: propertyDescriptor.configurable,\n enumerable: propertyDescriptor.enumerable,\n });\n });\n}\n\nlet mixinsApplied = false;\n\nfunction ensureMixinsApplied() {\n if (mixinsApplied) {\n return;\n }\n\n applyMixin(Aptos, Account, \"account\");\n applyMixin(Aptos, AccountAbstraction, \"abstraction\");\n applyMixin(Aptos, ANS, \"ans\");\n applyMixin(Aptos, Coin, \"coin\");\n applyMixin(Aptos, DigitalAsset, \"digitalAsset\");\n applyMixin(Aptos, Event, \"event\");\n applyMixin(Aptos, Faucet, \"faucet\");\n applyMixin(Aptos, FungibleAsset, \"fungibleAsset\");\n applyMixin(Aptos, General, \"general\");\n applyMixin(Aptos, Staking, \"staking\");\n applyMixin(Aptos, Transaction, \"transaction\");\n applyMixin(Aptos, Table, \"table\");\n applyMixin(Aptos, Keyless, \"keyless\");\n applyMixin(Aptos, AptosObject, \"object\");\n\n mixinsApplied = true;\n}\n"],"mappings":"AAGA,OAAS,WAAAA,MAAe,YACxB,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,QAAAC,MAAY,SACrB,OAAS,gBAAAC,MAAoB,iBAC7B,OAAS,UAAAC,MAAc,WACvB,OAAS,iBAAAC,MAAqB,kBAC9B,OAAS,WAAAC,MAAe,YACxB,OAAS,OAAAC,MAAW,QACpB,OAAS,WAAAC,MAAe,YACxB,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,SAAAC,MAAa,UACtB,OAAS,WAAAC,MAAe,YACxB,OAAS,eAAAC,MAAmB,WAC5B,OAAS,sBAAAC,MAA0B,wBA2B5B,MAAMC,CAAM,CAgDjB,YAAYC,EAAsB,CAChCC,EAAoB,EACpB,KAAK,OAASD,GAAU,IAAId,EAC5B,KAAK,QAAU,IAAID,EAAQ,KAAK,MAAM,EACtC,KAAK,YAAc,IAAIa,EAAmB,KAAK,MAAM,EACrD,KAAK,IAAM,IAAIN,EAAI,KAAK,MAAM,EAC9B,KAAK,KAAO,IAAIL,EAAK,KAAK,MAAM,EAChC,KAAK,aAAe,IAAIC,EAAa,KAAK,MAAM,EAChD,KAAK,OAAS,IAAIC,EAAO,KAAK,MAAM,EACpC,KAAK,cAAgB,IAAIC,EAAc,KAAK,MAAM,EAClD,KAAK,QAAU,IAAIC,EAAQ,KAAK,MAAM,EACtC,KAAK,QAAU,IAAIE,EAAQ,KAAK,MAAM,EACtC,KAAK,YAAc,IAAIC,EAAY,KAAK,MAAM,EAC9C,KAAK,MAAQ,IAAIC,EAAM,KAAK,MAAM,EAClC,KAAK,QAAU,IAAIC,EAAQ,KAAK,MAAM,EACtC,KAAK,OAAS,IAAIC,EAAY,KAAK,MAAM,CAC3C,CAEA,8BAA8BK,EAAiB,CAC7C,KAAK,OAAO,8BAA8BA,CAAM,CAClD,CACF,CA4BA,SAASC,EAAWC,EAAkBC,EAAgBC,EAAuB,CAE3E,OAAO,oBAAoBD,EAAU,SAAS,EAAE,QAASE,GAAiB,CACxE,MAAMC,EAAqB,OAAO,yBAAyBH,EAAU,UAAWE,CAAY,EACvFC,GAGL,OAAO,eAAeJ,EAAY,UAAWG,EAAc,CACzD,MAAO,YAAaE,EAAa,CAC/B,OAAQ,KAAaH,CAAa,EAAEC,CAAY,EAAE,GAAGE,CAAI,CAC3D,EACA,SAAUD,EAAmB,SAC7B,aAAcA,EAAmB,aACjC,WAAYA,EAAmB,UACjC,CAAC,CACH,CAAC,CACH,CAEA,IAAIE,EAAgB,GAEpB,SAAST,GAAsB,CACzBS,IAIJP,EAAWJ,EAAOd,EAAS,SAAS,EACpCkB,EAAWJ,EAAOD,EAAoB,aAAa,EACnDK,EAAWJ,EAAOP,EAAK,KAAK,EAC5BW,EAAWJ,EAAOZ,EAAM,MAAM,EAC9BgB,EAAWJ,EAAOX,EAAc,cAAc,EAC9Ce,EAAWJ,EAAO,MAAO,OAAO,EAChCI,EAAWJ,EAAOV,EAAQ,QAAQ,EAClCc,EAAWJ,EAAOT,EAAe,eAAe,EAChDa,EAAWJ,EAAOR,EAAS,SAAS,EACpCY,EAAWJ,EAAON,EAAS,SAAS,EACpCU,EAAWJ,EAAOL,EAAa,aAAa,EAC5CS,EAAWJ,EAAOJ,EAAO,OAAO,EAChCQ,EAAWJ,EAAOH,EAAS,SAAS,EACpCO,EAAWJ,EAAOF,EAAa,QAAQ,EAEvCa,EAAgB,GAClB","names":["Account","AptosConfig","Coin","DigitalAsset","Faucet","FungibleAsset","General","ANS","Staking","Transaction","Table","Keyless","AptosObject","AccountAbstraction","Aptos","config","ensureMixinsApplied","ignore","applyMixin","targetClass","baseClass","baseClassProp","propertyName","propertyDescriptor","args","mixinsApplied"]}
1
+ {"version":3,"sources":["../../../src/api/aptos.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"./account\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { Coin } from \"./coin\";\nimport { DigitalAsset } from \"./digitalAsset\";\nimport { Faucet } from \"./faucet\";\nimport { FungibleAsset } from \"./fungibleAsset\";\nimport { General } from \"./general\";\nimport { ANS } from \"./ans\";\nimport { Staking } from \"./staking\";\nimport { Transaction } from \"./transaction\";\nimport { Table } from \"./table\";\nimport { Keyless } from \"./keyless\";\nimport { AptosObject } from \"./object\";\nimport { AccountAbstraction } from \"./account/abstraction\";\n\n/**\n * The main entry point for interacting with the Aptos APIs,\n * providing access to various functionalities organized into\n * distinct namespaces.\n *\n * To utilize the SDK, instantiate a new Aptos object to gain\n * access to the complete range of SDK features.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for connecting to the Aptos testnet\n * const config = new AptosConfig({ network: Network.TESTNET });\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\nexport class Aptos {\n readonly config: AptosConfig;\n\n // Private fields to store lazy-loaded instances\n private _account?: Account;\n private _abstraction?: AccountAbstraction;\n private _ans?: ANS;\n private _coin?: Coin;\n private _digitalAsset?: DigitalAsset;\n private _faucet?: Faucet;\n private _fungibleAsset?: FungibleAsset;\n private _general?: General;\n private _staking?: Staking;\n private _transaction?: Transaction;\n private _table?: Table;\n private _keyless?: Keyless;\n private _object?: AptosObject;\n\n // Track which mixins have been applied\n static mixinsApplied = new Set<string>();\n\n /**\n * Initializes a new instance of the Aptos client with the provided configuration settings.\n * This allows you to interact with various Aptos functionalities such as accounts, transactions, and events.\n *\n * @param settings - Configuration settings for the Aptos client.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a new Aptos client with default settings\n * const config = new AptosConfig({ network: Network.TESTNET }); // Specify your own settings if needed\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n constructor(config?: AptosConfig) {\n this.config = config ?? new AptosConfig();\n }\n\n /**\n * Lazy-loaded getter for Account functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get account(): Account {\n if (!this._account) {\n ensureMixinApplied(Aptos, Account, \"account\");\n this._account = new Account(this.config);\n }\n return this._account;\n }\n\n /**\n * Lazy-loaded getter for AccountAbstraction functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get abstraction(): AccountAbstraction {\n if (!this._abstraction) {\n ensureMixinApplied(Aptos, AccountAbstraction, \"abstraction\");\n this._abstraction = new AccountAbstraction(this.config);\n }\n return this._abstraction;\n }\n\n /**\n * Lazy-loaded getter for ANS functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get ans(): ANS {\n if (!this._ans) {\n ensureMixinApplied(Aptos, ANS, \"ans\");\n this._ans = new ANS(this.config);\n }\n return this._ans;\n }\n\n /**\n * Lazy-loaded getter for Coin functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get coin(): Coin {\n if (!this._coin) {\n ensureMixinApplied(Aptos, Coin, \"coin\");\n this._coin = new Coin(this.config);\n }\n return this._coin;\n }\n\n /**\n * Lazy-loaded getter for DigitalAsset functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get digitalAsset(): DigitalAsset {\n if (!this._digitalAsset) {\n ensureMixinApplied(Aptos, DigitalAsset, \"digitalAsset\");\n this._digitalAsset = new DigitalAsset(this.config);\n }\n return this._digitalAsset;\n }\n\n /**\n * Lazy-loaded getter for Faucet functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get faucet(): Faucet {\n if (!this._faucet) {\n ensureMixinApplied(Aptos, Faucet, \"faucet\");\n this._faucet = new Faucet(this.config);\n }\n return this._faucet;\n }\n\n /**\n * Lazy-loaded getter for FungibleAsset functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get fungibleAsset(): FungibleAsset {\n if (!this._fungibleAsset) {\n ensureMixinApplied(Aptos, FungibleAsset, \"fungibleAsset\");\n this._fungibleAsset = new FungibleAsset(this.config);\n }\n return this._fungibleAsset;\n }\n\n /**\n * Lazy-loaded getter for General functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get general(): General {\n if (!this._general) {\n ensureMixinApplied(Aptos, General, \"general\");\n this._general = new General(this.config);\n }\n return this._general;\n }\n\n /**\n * Lazy-loaded getter for Staking functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get staking(): Staking {\n if (!this._staking) {\n ensureMixinApplied(Aptos, Staking, \"staking\");\n this._staking = new Staking(this.config);\n }\n return this._staking;\n }\n\n /**\n * Lazy-loaded getter for Transaction functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get transaction(): Transaction {\n if (!this._transaction) {\n ensureMixinApplied(Aptos, Transaction, \"transaction\");\n this._transaction = new Transaction(this.config);\n }\n return this._transaction;\n }\n\n /**\n * Lazy-loaded getter for Table functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get table(): Table {\n if (!this._table) {\n ensureMixinApplied(Aptos, Table, \"table\");\n this._table = new Table(this.config);\n }\n return this._table;\n }\n\n /**\n * Lazy-loaded getter for Keyless functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get keyless(): Keyless {\n if (!this._keyless) {\n ensureMixinApplied(Aptos, Keyless, \"keyless\");\n this._keyless = new Keyless(this.config);\n }\n return this._keyless;\n }\n\n /**\n * Lazy-loaded getter for AptosObject functionality.\n * Only instantiates and applies mixin when first accessed.\n */\n get object(): AptosObject {\n if (!this._object) {\n ensureMixinApplied(Aptos, AptosObject, \"object\");\n this._object = new AptosObject(this.config);\n }\n return this._object;\n }\n\n setIgnoreTransactionSubmitter(ignore: boolean) {\n this.config.setIgnoreTransactionSubmitter(ignore);\n }\n}\n\n// extends Aptos interface so all the methods and properties\n// from the other classes will be recognized by typescript.\n// Note: Mixins are applied lazily when the corresponding property is first accessed.\nexport interface Aptos\n extends Account,\n AccountAbstraction,\n ANS,\n Coin,\n DigitalAsset,\n Faucet,\n FungibleAsset,\n General,\n Keyless,\n Staking,\n Table,\n AptosObject,\n Omit<Transaction, \"build\" | \"simulate\" | \"submit\" | \"batch\"> {}\n\n/**\nIn TypeScript, we can't inherit or extend from more than one class,\nMixins helps us to get around that by creating a partial classes\nthat we can combine to form a single class that contains all the methods and properties from the partial classes.\n{@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}\n\nHere, we combine any subclass and the Aptos class.\n * @group Client\n*/\nfunction applyMixin(targetClass: any, baseClass: any, baseClassProp: string) {\n // Mixin instance methods\n Object.getOwnPropertyNames(baseClass.prototype).forEach((propertyName) => {\n const propertyDescriptor = Object.getOwnPropertyDescriptor(baseClass.prototype, propertyName);\n if (!propertyDescriptor) return;\n\n // Skip constructor and properties that already exist\n if (propertyName === \"constructor\" || targetClass.prototype[propertyName]) {\n return;\n }\n\n // Define new method that calls through baseClassProp\n Object.defineProperty(targetClass.prototype, propertyName, {\n value: function (...args: any[]) {\n return (this as any)[baseClassProp][propertyName](...args);\n },\n writable: propertyDescriptor.writable,\n configurable: propertyDescriptor.configurable,\n enumerable: propertyDescriptor.enumerable,\n });\n });\n}\n\n/**\n * Ensures a mixin is applied only once when the corresponding functionality is first accessed.\n * This enables lazy loading - mixins are only applied when their functionality is actually used.\n */\nfunction ensureMixinApplied(targetClass: any, baseClass: any, baseClassProp: string) {\n const mixinKey = `${targetClass.name}-${baseClass.name}-${baseClassProp}`;\n if (Aptos.mixinsApplied.has(mixinKey)) {\n return;\n }\n\n applyMixin(targetClass, baseClass, baseClassProp);\n Aptos.mixinsApplied.add(mixinKey);\n}\n"],"mappings":"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","names":["Account","AptosConfig","Coin","DigitalAsset","Faucet","FungibleAsset","General","ANS","Staking","Transaction","Table","Keyless","AptosObject","AccountAbstraction","_Aptos","config","ensureMixinApplied","ignore","Aptos","applyMixin","targetClass","baseClass","baseClassProp","propertyName","propertyDescriptor","args","mixinKey"]}
@@ -5,13 +5,13 @@ import '../types/indexer.mjs';
5
5
  import '../types/generated/operations.mjs';
6
6
  import '../types/generated/types.mjs';
7
7
  import '../Ed25519Account-CPwej6wB.mjs';
8
- import '../core/crypto/types.mjs';
8
+ import './account/abstraction.mjs';
9
9
  import '../utils/apiEndpoints.mjs';
10
10
  import '../utils/const.mjs';
11
11
  import '../core/common.mjs';
12
+ import '../core/crypto/types.mjs';
12
13
  import '../internal/account.mjs';
13
14
  import '../account/MultiEd25519Account.mjs';
14
- import './account/abstraction.mjs';
15
15
  import './coin.mjs';
16
16
  import './digitalAsset.mjs';
17
17
  import '../internal/digitalAsset.mjs';
@@ -42,8 +42,8 @@ export { DeserializableClass, normalizeBundle } from './utils/normalizeBundle.mj
42
42
  export { base64UrlDecode, base64UrlToBytes, convertAmountFromHumanReadableToOnChain, convertAmountFromOnChainToHumanReadable, floorToWholeHour, getErrorMessage, getFunctionParts, isEncodedStruct, isValidFunctionInfo, nowInSeconds, pairedFaMetadataAddress, parseEncodedStruct, sleep, truncateAddress } from './utils/helpers.mjs';
43
43
  import './api/account.mjs';
44
44
  import './types/generated/types.mjs';
45
- import './internal/account.mjs';
46
45
  import './api/account/abstraction.mjs';
46
+ import './internal/account.mjs';
47
47
  import './api/coin.mjs';
48
48
  import './api/digitalAsset.mjs';
49
49
  import './internal/digitalAsset.mjs';
@@ -1,4 +1,4 @@
1
- import { b4 as InputScriptData, ae as TransactionPayloadScript, b1 as InputEntryFunctionDataWithRemoteABI, af as TransactionPayloadEntryFunction, b3 as InputMultiSigDataWithRemoteABI, ag as TransactionPayloadMultiSig, a$ as InputEntryFunctionDataWithABI, b0 as InputMultiSigDataWithABI, b8 as InputViewFunctionDataWithRemoteABI, ah as EntryFunction, b9 as InputViewFunctionDataWithABI, A as AptosConfig, m as AccountAddressInput, aW as AnyTransactionPayloadInstance, aT as InputGenerateTransactionOptions, a5 as RawTransaction, al as TransactionInnerPayload, bd as InputGenerateSingleSignerRawTransactionArgs, at as SimpleTransaction, be as InputGenerateMultiAgentRawTransactionArgs, au as MultiAgentTransaction, bh as InputSimulateTransactionData, C as PublicKey, $ as AccountAuthenticatorNoAccountAuthenticator, X as AccountAuthenticatorEd25519, Z as AccountAuthenticatorSingleKey, _ as AccountAuthenticatorMultiKey, bn as InputSubmitTransactionData } from '../../account-BortO8g2.mjs';
1
+ import { b4 as InputScriptData, ae as TransactionPayloadScript, b1 as InputEntryFunctionDataWithRemoteABI, af as TransactionPayloadEntryFunction, b3 as InputMultiSigDataWithRemoteABI, ag as TransactionPayloadMultiSig, a$ as InputEntryFunctionDataWithABI, b0 as InputMultiSigDataWithABI, b8 as InputViewFunctionDataWithRemoteABI, ah as EntryFunction, b9 as InputViewFunctionDataWithABI, A as AptosConfig, m as AccountAddressInput, aW as AnyTransactionPayloadInstance, aT as InputGenerateTransactionOptions, a5 as RawTransaction, al as TransactionInnerPayload, bd as InputGenerateSingleSignerRawTransactionArgs, at as SimpleTransaction, be as InputGenerateMultiAgentRawTransactionArgs, au as MultiAgentTransaction, bh as InputSimulateTransactionData, C as PublicKey, X as AccountAuthenticatorEd25519, Z as AccountAuthenticatorSingleKey, _ as AccountAuthenticatorMultiKey, $ as AccountAuthenticatorNoAccountAuthenticator, bn as InputSubmitTransactionData } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -149,7 +149,7 @@ declare function generateSignedTransactionForSimulation(args: InputSimulateTrans
149
149
  * @group Implementation
150
150
  * @category Transactions
151
151
  */
152
- declare function getAuthenticatorForSimulation(publicKey?: PublicKey): AccountAuthenticatorNoAccountAuthenticator | AccountAuthenticatorEd25519 | AccountAuthenticatorSingleKey | AccountAuthenticatorMultiKey;
152
+ declare function getAuthenticatorForSimulation(publicKey?: PublicKey): AccountAuthenticatorEd25519 | AccountAuthenticatorSingleKey | AccountAuthenticatorMultiKey | AccountAuthenticatorNoAccountAuthenticator;
153
153
  /**
154
154
  * Generate a signed transaction ready for submission to the blockchain.
155
155
  * This function prepares the transaction by authenticating the sender and any additional signers based on the provided arguments.
package/package.json CHANGED
@@ -99,7 +99,7 @@
99
99
  "typedoc-plugin-missing-exports": "^4.1.0",
100
100
  "typescript": "^5.8.3"
101
101
  },
102
- "version": "5.1.1-side-effect-free.0",
102
+ "version": "5.1.1-side-effect-free.1",
103
103
  "scripts": {
104
104
  "build:clean": "rm -rf dist",
105
105
  "build": "pnpm build:clean && tsup",
package/src/api/aptos.ts CHANGED
@@ -44,29 +44,23 @@ import { AccountAbstraction } from "./account/abstraction";
44
44
  export class Aptos {
45
45
  readonly config: AptosConfig;
46
46
 
47
- readonly account: Account;
47
+ // Private fields to store lazy-loaded instances
48
+ private _account?: Account;
49
+ private _abstraction?: AccountAbstraction;
50
+ private _ans?: ANS;
51
+ private _coin?: Coin;
52
+ private _digitalAsset?: DigitalAsset;
53
+ private _faucet?: Faucet;
54
+ private _fungibleAsset?: FungibleAsset;
55
+ private _general?: General;
56
+ private _staking?: Staking;
57
+ private _transaction?: Transaction;
58
+ private _table?: Table;
59
+ private _keyless?: Keyless;
60
+ private _object?: AptosObject;
48
61
 
49
- readonly ans: ANS;
50
-
51
- readonly coin: Coin;
52
-
53
- readonly digitalAsset: DigitalAsset;
54
-
55
- readonly faucet: Faucet;
56
-
57
- readonly fungibleAsset: FungibleAsset;
58
-
59
- readonly general: General;
60
-
61
- readonly staking: Staking;
62
-
63
- readonly transaction: Transaction;
64
-
65
- readonly table: Table;
66
-
67
- readonly keyless: Keyless;
68
-
69
- readonly object: AptosObject;
62
+ // Track which mixins have been applied
63
+ static mixinsApplied = new Set<string>();
70
64
 
71
65
  /**
72
66
  * Initializes a new instance of the Aptos client with the provided configuration settings.
@@ -90,21 +84,163 @@ export class Aptos {
90
84
  * @group Client
91
85
  */
92
86
  constructor(config?: AptosConfig) {
93
- ensureMixinsApplied();
94
87
  this.config = config ?? new AptosConfig();
95
- this.account = new Account(this.config);
96
- this.abstraction = new AccountAbstraction(this.config);
97
- this.ans = new ANS(this.config);
98
- this.coin = new Coin(this.config);
99
- this.digitalAsset = new DigitalAsset(this.config);
100
- this.faucet = new Faucet(this.config);
101
- this.fungibleAsset = new FungibleAsset(this.config);
102
- this.general = new General(this.config);
103
- this.staking = new Staking(this.config);
104
- this.transaction = new Transaction(this.config);
105
- this.table = new Table(this.config);
106
- this.keyless = new Keyless(this.config);
107
- this.object = new AptosObject(this.config);
88
+ }
89
+
90
+ /**
91
+ * Lazy-loaded getter for Account functionality.
92
+ * Only instantiates and applies mixin when first accessed.
93
+ */
94
+ get account(): Account {
95
+ if (!this._account) {
96
+ ensureMixinApplied(Aptos, Account, "account");
97
+ this._account = new Account(this.config);
98
+ }
99
+ return this._account;
100
+ }
101
+
102
+ /**
103
+ * Lazy-loaded getter for AccountAbstraction functionality.
104
+ * Only instantiates and applies mixin when first accessed.
105
+ */
106
+ get abstraction(): AccountAbstraction {
107
+ if (!this._abstraction) {
108
+ ensureMixinApplied(Aptos, AccountAbstraction, "abstraction");
109
+ this._abstraction = new AccountAbstraction(this.config);
110
+ }
111
+ return this._abstraction;
112
+ }
113
+
114
+ /**
115
+ * Lazy-loaded getter for ANS functionality.
116
+ * Only instantiates and applies mixin when first accessed.
117
+ */
118
+ get ans(): ANS {
119
+ if (!this._ans) {
120
+ ensureMixinApplied(Aptos, ANS, "ans");
121
+ this._ans = new ANS(this.config);
122
+ }
123
+ return this._ans;
124
+ }
125
+
126
+ /**
127
+ * Lazy-loaded getter for Coin functionality.
128
+ * Only instantiates and applies mixin when first accessed.
129
+ */
130
+ get coin(): Coin {
131
+ if (!this._coin) {
132
+ ensureMixinApplied(Aptos, Coin, "coin");
133
+ this._coin = new Coin(this.config);
134
+ }
135
+ return this._coin;
136
+ }
137
+
138
+ /**
139
+ * Lazy-loaded getter for DigitalAsset functionality.
140
+ * Only instantiates and applies mixin when first accessed.
141
+ */
142
+ get digitalAsset(): DigitalAsset {
143
+ if (!this._digitalAsset) {
144
+ ensureMixinApplied(Aptos, DigitalAsset, "digitalAsset");
145
+ this._digitalAsset = new DigitalAsset(this.config);
146
+ }
147
+ return this._digitalAsset;
148
+ }
149
+
150
+ /**
151
+ * Lazy-loaded getter for Faucet functionality.
152
+ * Only instantiates and applies mixin when first accessed.
153
+ */
154
+ get faucet(): Faucet {
155
+ if (!this._faucet) {
156
+ ensureMixinApplied(Aptos, Faucet, "faucet");
157
+ this._faucet = new Faucet(this.config);
158
+ }
159
+ return this._faucet;
160
+ }
161
+
162
+ /**
163
+ * Lazy-loaded getter for FungibleAsset functionality.
164
+ * Only instantiates and applies mixin when first accessed.
165
+ */
166
+ get fungibleAsset(): FungibleAsset {
167
+ if (!this._fungibleAsset) {
168
+ ensureMixinApplied(Aptos, FungibleAsset, "fungibleAsset");
169
+ this._fungibleAsset = new FungibleAsset(this.config);
170
+ }
171
+ return this._fungibleAsset;
172
+ }
173
+
174
+ /**
175
+ * Lazy-loaded getter for General functionality.
176
+ * Only instantiates and applies mixin when first accessed.
177
+ */
178
+ get general(): General {
179
+ if (!this._general) {
180
+ ensureMixinApplied(Aptos, General, "general");
181
+ this._general = new General(this.config);
182
+ }
183
+ return this._general;
184
+ }
185
+
186
+ /**
187
+ * Lazy-loaded getter for Staking functionality.
188
+ * Only instantiates and applies mixin when first accessed.
189
+ */
190
+ get staking(): Staking {
191
+ if (!this._staking) {
192
+ ensureMixinApplied(Aptos, Staking, "staking");
193
+ this._staking = new Staking(this.config);
194
+ }
195
+ return this._staking;
196
+ }
197
+
198
+ /**
199
+ * Lazy-loaded getter for Transaction functionality.
200
+ * Only instantiates and applies mixin when first accessed.
201
+ */
202
+ get transaction(): Transaction {
203
+ if (!this._transaction) {
204
+ ensureMixinApplied(Aptos, Transaction, "transaction");
205
+ this._transaction = new Transaction(this.config);
206
+ }
207
+ return this._transaction;
208
+ }
209
+
210
+ /**
211
+ * Lazy-loaded getter for Table functionality.
212
+ * Only instantiates and applies mixin when first accessed.
213
+ */
214
+ get table(): Table {
215
+ if (!this._table) {
216
+ ensureMixinApplied(Aptos, Table, "table");
217
+ this._table = new Table(this.config);
218
+ }
219
+ return this._table;
220
+ }
221
+
222
+ /**
223
+ * Lazy-loaded getter for Keyless functionality.
224
+ * Only instantiates and applies mixin when first accessed.
225
+ */
226
+ get keyless(): Keyless {
227
+ if (!this._keyless) {
228
+ ensureMixinApplied(Aptos, Keyless, "keyless");
229
+ this._keyless = new Keyless(this.config);
230
+ }
231
+ return this._keyless;
232
+ }
233
+
234
+ /**
235
+ * Lazy-loaded getter for AptosObject functionality.
236
+ * Only instantiates and applies mixin when first accessed.
237
+ */
238
+ get object(): AptosObject {
239
+ if (!this._object) {
240
+ ensureMixinApplied(Aptos, AptosObject, "object");
241
+ this._object = new AptosObject(this.config);
242
+ }
243
+ return this._object;
108
244
  }
109
245
 
110
246
  setIgnoreTransactionSubmitter(ignore: boolean) {
@@ -114,12 +250,13 @@ export class Aptos {
114
250
 
115
251
  // extends Aptos interface so all the methods and properties
116
252
  // from the other classes will be recognized by typescript.
253
+ // Note: Mixins are applied lazily when the corresponding property is first accessed.
117
254
  export interface Aptos
118
255
  extends Account,
256
+ AccountAbstraction,
119
257
  ANS,
120
258
  Coin,
121
259
  DigitalAsset,
122
- Event,
123
260
  Faucet,
124
261
  FungibleAsset,
125
262
  General,
@@ -130,7 +267,7 @@ export interface Aptos
130
267
  Omit<Transaction, "build" | "simulate" | "submit" | "batch"> {}
131
268
 
132
269
  /**
133
- In TypeScript, we cant inherit or extend from more than one class,
270
+ In TypeScript, we can't inherit or extend from more than one class,
134
271
  Mixins helps us to get around that by creating a partial classes
135
272
  that we can combine to form a single class that contains all the methods and properties from the partial classes.
136
273
  {@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}
@@ -144,6 +281,11 @@ function applyMixin(targetClass: any, baseClass: any, baseClassProp: string) {
144
281
  const propertyDescriptor = Object.getOwnPropertyDescriptor(baseClass.prototype, propertyName);
145
282
  if (!propertyDescriptor) return;
146
283
 
284
+ // Skip constructor and properties that already exist
285
+ if (propertyName === "constructor" || targetClass.prototype[propertyName]) {
286
+ return;
287
+ }
288
+
147
289
  // Define new method that calls through baseClassProp
148
290
  Object.defineProperty(targetClass.prototype, propertyName, {
149
291
  value: function (...args: any[]) {
@@ -156,27 +298,16 @@ function applyMixin(targetClass: any, baseClass: any, baseClassProp: string) {
156
298
  });
157
299
  }
158
300
 
159
- let mixinsApplied = false;
160
-
161
- function ensureMixinsApplied() {
162
- if (mixinsApplied) {
301
+ /**
302
+ * Ensures a mixin is applied only once when the corresponding functionality is first accessed.
303
+ * This enables lazy loading - mixins are only applied when their functionality is actually used.
304
+ */
305
+ function ensureMixinApplied(targetClass: any, baseClass: any, baseClassProp: string) {
306
+ const mixinKey = `${targetClass.name}-${baseClass.name}-${baseClassProp}`;
307
+ if (Aptos.mixinsApplied.has(mixinKey)) {
163
308
  return;
164
309
  }
165
310
 
166
- applyMixin(Aptos, Account, "account");
167
- applyMixin(Aptos, AccountAbstraction, "abstraction");
168
- applyMixin(Aptos, ANS, "ans");
169
- applyMixin(Aptos, Coin, "coin");
170
- applyMixin(Aptos, DigitalAsset, "digitalAsset");
171
- applyMixin(Aptos, Event, "event");
172
- applyMixin(Aptos, Faucet, "faucet");
173
- applyMixin(Aptos, FungibleAsset, "fungibleAsset");
174
- applyMixin(Aptos, General, "general");
175
- applyMixin(Aptos, Staking, "staking");
176
- applyMixin(Aptos, Transaction, "transaction");
177
- applyMixin(Aptos, Table, "table");
178
- applyMixin(Aptos, Keyless, "keyless");
179
- applyMixin(Aptos, AptosObject, "object");
180
-
181
- mixinsApplied = true;
311
+ applyMixin(targetClass, baseClass, baseClassProp);
312
+ Aptos.mixinsApplied.add(mixinKey);
182
313
  }