@aeternity/aepp-sdk 14.1.1 → 15.0.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.
Files changed (84) hide show
  1. package/dist/aepp-sdk.browser-script.cjs +1 -1
  2. package/dist/aepp-sdk.browser-script.cjs.map +1 -1
  3. package/dist/aepp-sdk.browser.cjs +1 -1
  4. package/dist/aepp-sdk.browser.cjs.map +1 -1
  5. package/dist/aepp-sdk.cjs +3112 -506
  6. package/dist/aepp-sdk.cjs.map +1 -1
  7. package/es/account/Base.d.ts +6 -1
  8. package/es/account/Base.js.map +1 -1
  9. package/es/account/Generalized.d.ts +1 -1
  10. package/es/account/Generalized.js +7 -1
  11. package/es/account/Generalized.js.map +1 -1
  12. package/es/apis/node/models/index.d.ts +405 -79
  13. package/es/apis/node/models/index.js.map +1 -1
  14. package/es/apis/node/models/mappers.d.ts +54 -4
  15. package/es/apis/node/models/mappers.js +1910 -500
  16. package/es/apis/node/models/mappers.js.map +1 -1
  17. package/es/apis/node/node.d.ts +28 -6
  18. package/es/apis/node/node.js +276 -5
  19. package/es/apis/node/node.js.map +1 -1
  20. package/es/channel/Contract.d.ts +5 -0
  21. package/es/channel/Contract.js +8 -2
  22. package/es/channel/Contract.js.map +1 -1
  23. package/es/channel/handlers.js +3 -3
  24. package/es/channel/handlers.js.map +1 -1
  25. package/es/contract/ga.d.ts +5 -2
  26. package/es/contract/ga.js +53 -21
  27. package/es/contract/ga.js.map +1 -1
  28. package/es/index-browser.d.ts +3 -1
  29. package/es/index-browser.js +2 -1
  30. package/es/index-browser.js.map +1 -1
  31. package/es/tx/builder/constants.d.ts +13 -2
  32. package/es/tx/builder/constants.js +12 -1
  33. package/es/tx/builder/constants.js.map +1 -1
  34. package/es/tx/builder/entry/index.js +6 -0
  35. package/es/tx/builder/entry/index.js.map +1 -1
  36. package/es/tx/builder/entry/schema.d.ts +10 -10
  37. package/es/tx/builder/field-types/abi-version.js +6 -4
  38. package/es/tx/builder/field-types/abi-version.js.map +1 -1
  39. package/es/tx/builder/field-types/ct-version.d.ts +19 -0
  40. package/es/tx/builder/field-types/ct-version.js +27 -1
  41. package/es/tx/builder/field-types/ct-version.js.map +1 -1
  42. package/es/tx/builder/field-types/fee.d.ts +9 -7
  43. package/es/tx/builder/field-types/fee.js +75 -66
  44. package/es/tx/builder/field-types/fee.js.map +1 -1
  45. package/es/tx/builder/field-types/gas-limit.d.ts +5 -3
  46. package/es/tx/builder/field-types/gas-limit.js +25 -14
  47. package/es/tx/builder/field-types/gas-limit.js.map +1 -1
  48. package/es/tx/builder/field-types/gas-price.d.ts +6 -4
  49. package/es/tx/builder/field-types/gas-price.js +91 -21
  50. package/es/tx/builder/field-types/gas-price.js.map +1 -1
  51. package/es/tx/builder/field-types/interface.d.ts +20 -0
  52. package/es/tx/builder/field-types/interface.js +17 -1
  53. package/es/tx/builder/field-types/interface.js.map +1 -1
  54. package/es/tx/builder/field-types/name-fee.d.ts +3 -2
  55. package/es/tx/builder/field-types/name-fee.js +6 -0
  56. package/es/tx/builder/field-types/name-fee.js.map +1 -1
  57. package/es/tx/builder/field-types/pointers.d.ts +2 -1
  58. package/es/tx/builder/field-types/pointers.js +6 -2
  59. package/es/tx/builder/field-types/pointers.js.map +1 -1
  60. package/es/tx/builder/field-types/transaction.d.ts +4 -1
  61. package/es/tx/builder/field-types/transaction.js +18 -3
  62. package/es/tx/builder/field-types/transaction.js.map +1 -1
  63. package/es/tx/builder/field-types/with-formatting.d.ts +1 -1
  64. package/es/tx/builder/field-types/with-formatting.js +1 -1
  65. package/es/tx/builder/field-types/with-formatting.js.map +1 -1
  66. package/es/tx/builder/index.d.ts +13 -0
  67. package/es/tx/builder/index.js +92 -5
  68. package/es/tx/builder/index.js.map +1 -1
  69. package/es/tx/builder/protocol-parameters.d.ts +134 -0
  70. package/es/tx/builder/protocol-parameters.js +539 -0
  71. package/es/tx/builder/protocol-parameters.js.map +1 -0
  72. package/es/tx/builder/schema.d.ts +156 -155
  73. package/es/tx/builder/schema.js +5 -1
  74. package/es/tx/builder/schema.js.map +1 -1
  75. package/es/tx/execution-cost.js +5 -5
  76. package/es/tx/execution-cost.js.map +1 -1
  77. package/es/tx/transaction-signer.js +2 -2
  78. package/es/tx/transaction-signer.js.map +1 -1
  79. package/es/tx/validator.js +4 -4
  80. package/es/tx/validator.js.map +1 -1
  81. package/es/utils/wrap-proxy.d.ts +10 -0
  82. package/es/utils/wrap-proxy.js +18 -0
  83. package/es/utils/wrap-proxy.js.map +1 -1
  84. package/package.json +15 -3
@@ -2,6 +2,7 @@ import { Encoded } from '../utils/encoder.js';
2
2
  import Node from '../Node.js';
3
3
  import CompilerBase from '../contract/compiler/Base.js';
4
4
  import { Int } from '../tx/builder/constants.js';
5
+ import type { ProtocolParametersOption } from '../tx/builder/protocol-parameters.js';
5
6
  import { AciValue, Domain } from '../utils/typed-data.js';
6
7
  interface AuthData {
7
8
  fee?: Int;
@@ -23,6 +24,10 @@ export default abstract class AccountBase {
23
24
  * @param options - Options
24
25
  * @param options.innerTx - Sign as inner transaction for PayingFor
25
26
  * @param options.authData - Object with gaMeta params
27
+ * @param options.protocolParameters - Consensus parameters to build the wrapping `GaMetaTx` of a
28
+ * generalized account against, requested from node if not provided. Not forwarded to an account
29
+ * behind a wallet RPC connection — such an account builds against the parameters of the node the
30
+ * wallet is connected to
26
31
  * @returns Signed transaction
27
32
  */
28
33
  abstract signTransaction(tx: Encoded.Transaction, options: {
@@ -33,7 +38,7 @@ export default abstract class AccountBase {
33
38
  onCompiler?: CompilerBase;
34
39
  aeppOrigin?: string;
35
40
  aeppRpcClientId?: string;
36
- }): Promise<Encoded.Transaction>;
41
+ } & ProtocolParametersOption): Promise<Encoded.Transaction>;
37
42
  /**
38
43
  * Sign message
39
44
  * @param message - Message to sign
@@ -1 +1 @@
1
- {"version":3,"file":"Base.js","names":["AccountBase"],"sources":["../../src/account/Base.ts"],"sourcesContent":["import { Encoded } from '../utils/encoder.js';\nimport Node from '../Node.js';\nimport CompilerBase from '../contract/compiler/Base.js';\nimport { Int } from '../tx/builder/constants.js';\nimport { AciValue, Domain } from '../utils/typed-data.js';\n\ninterface AuthData {\n fee?: Int;\n gasLimit?: number;\n gasPrice?: Int;\n callData?: Encoded.ContractBytearray;\n sourceCode?: string;\n args?: any[];\n}\n\n/**\n * Account is one of the three basic building blocks of an\n * {@link AeSdk} and provides access to a signing key pair.\n * @category account\n */\nexport default abstract class AccountBase {\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param options - Options\n * @param options.innerTx - Sign as inner transaction for PayingFor\n * @param options.authData - Object with gaMeta params\n * @returns Signed transaction\n */\n abstract signTransaction(\n tx: Encoded.Transaction,\n options: {\n innerTx?: boolean;\n networkId?: string;\n authData?: AuthData | ((tx: Encoded.Transaction) => Promise<AuthData>);\n onNode?: Node;\n onCompiler?: CompilerBase;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Transaction>;\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param options - Options\n * @returns Signature\n */\n abstract signMessage(\n message: string,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Sign typed data\n * @param data - Encoded data to sign\n * @param aci - Type of data to sign\n * @param options - Options\n * @returns Signature\n */\n abstract signTypedData(\n data: Encoded.ContractBytearray,\n aci: AciValue,\n options?: Domain & {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Signature>;\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signature\n * @deprecated Use `unsafeSign` method instead\n */\n abstract sign(\n data: string | Uint8Array,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signature\n */\n abstract unsafeSign(\n data: string | Uint8Array,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Account address\n */\n readonly address!: Encoded.AccountAddress;\n\n /**\n * Sign delegation, works only in Ceres\n * @param delegation - Delegation to sign\n * @param options - Options\n * @returns Signature\n */\n abstract signDelegation(\n delegation: Encoded.Bytearray,\n options?: {\n networkId?: string;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Signature>;\n}\n"],"mappings":"AAeA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAeA,WAAW,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Base.js","names":["AccountBase"],"sources":["../../src/account/Base.ts"],"sourcesContent":["import { Encoded } from '../utils/encoder.js';\nimport Node from '../Node.js';\nimport CompilerBase from '../contract/compiler/Base.js';\nimport { Int } from '../tx/builder/constants.js';\nimport type { ProtocolParametersOption } from '../tx/builder/protocol-parameters.js';\nimport { AciValue, Domain } from '../utils/typed-data.js';\n\ninterface AuthData {\n fee?: Int;\n gasLimit?: number;\n gasPrice?: Int;\n callData?: Encoded.ContractBytearray;\n sourceCode?: string;\n args?: any[];\n}\n\n/**\n * Account is one of the three basic building blocks of an\n * {@link AeSdk} and provides access to a signing key pair.\n * @category account\n */\nexport default abstract class AccountBase {\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param options - Options\n * @param options.innerTx - Sign as inner transaction for PayingFor\n * @param options.authData - Object with gaMeta params\n * @param options.protocolParameters - Consensus parameters to build the wrapping `GaMetaTx` of a\n * generalized account against, requested from node if not provided. Not forwarded to an account\n * behind a wallet RPC connection — such an account builds against the parameters of the node the\n * wallet is connected to\n * @returns Signed transaction\n */\n abstract signTransaction(\n tx: Encoded.Transaction,\n options: {\n innerTx?: boolean;\n networkId?: string;\n authData?: AuthData | ((tx: Encoded.Transaction) => Promise<AuthData>);\n onNode?: Node;\n onCompiler?: CompilerBase;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n } & ProtocolParametersOption,\n ): Promise<Encoded.Transaction>;\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param options - Options\n * @returns Signature\n */\n abstract signMessage(\n message: string,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Sign typed data\n * @param data - Encoded data to sign\n * @param aci - Type of data to sign\n * @param options - Options\n * @returns Signature\n */\n abstract signTypedData(\n data: Encoded.ContractBytearray,\n aci: AciValue,\n options?: Domain & {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Signature>;\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signature\n * @deprecated Use `unsafeSign` method instead\n */\n abstract sign(\n data: string | Uint8Array,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signature\n */\n abstract unsafeSign(\n data: string | Uint8Array,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Account address\n */\n readonly address!: Encoded.AccountAddress;\n\n /**\n * Sign delegation, works only in Ceres\n * @param delegation - Delegation to sign\n * @param options - Options\n * @returns Signature\n */\n abstract signDelegation(\n delegation: Encoded.Bytearray,\n options?: {\n networkId?: string;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Signature>;\n}\n"],"mappings":"AAgBA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAeA,WAAW,CAAC","ignoreList":[]}
@@ -19,5 +19,5 @@ export default class AccountGeneralized extends AccountBase {
19
19
  signMessage(): Promise<Uint8Array>;
20
20
  signTypedData(): Promise<Encoded.Signature>;
21
21
  signDelegation(): Promise<Encoded.Signature>;
22
- signTransaction(tx: Encoded.Transaction, { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1]): Promise<Encoded.Transaction>;
22
+ signTransaction(tx: Encoded.Transaction, { authData, onCompiler, onNode, protocolParameters, }: Parameters<AccountBase['signTransaction']>[1]): Promise<Encoded.Transaction>;
23
23
  }
@@ -57,7 +57,8 @@ export default class AccountGeneralized extends AccountBase {
57
57
  async signTransaction(tx, {
58
58
  authData,
59
59
  onCompiler,
60
- onNode
60
+ onNode,
61
+ protocolParameters
61
62
  }) {
62
63
  if (authData == null || onCompiler == null || onNode == null) {
63
64
  throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);
@@ -105,6 +106,11 @@ export default class AccountGeneralized extends AccountBase {
105
106
  fee,
106
107
  gasLimit,
107
108
  gasPrice,
109
+ // the wrapping transaction is priced by the same parameters the caller asked the inner one
110
+ // to be built against, `buildTxAsync` requests them from node if not provided
111
+ ...(protocolParameters != null && {
112
+ protocolParameters
113
+ }),
108
114
  onNode
109
115
  });
110
116
  return buildTx({
@@ -1 +1 @@
1
- {"version":3,"file":"Generalized.js","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","buildTxAsync","buildTx","Tag","_authFun","WeakMap","AccountGeneralized","constructor","address","_classPrivateFieldInitSpec","sign","unsafeSign","signMessage","signTypedData","signDelegation","signTransaction","tx","authData","onCompiler","onNode","callData","sourceCode","args","fee","gasLimit","gasPrice","authCallData","_classPrivateFieldGet","account","kind","_classPrivateFieldSet","authFun","contract","initialize","_calldata","encode","_name","gaMetaTx","tag","GaMetaTx","SignedTx","encodedTx","signatures","gaId"],"sources":["../../src/account/Generalized.ts"],"sourcesContent":["import AccountBase from './Base.js';\nimport {\n ArgumentError,\n InternalError,\n InvalidAuthDataError,\n NotImplementedError,\n} from '../utils/errors.js';\nimport { decode, Encoded } from '../utils/encoder.js';\nimport { getAccount } from '../chain.js';\nimport Contract from '../contract/Contract.js';\nimport { buildTxAsync, buildTx } from '../tx/builder/index.js';\nimport { Tag } from '../tx/builder/constants.js';\n\n/**\n * Generalized account class\n * @category account generalized\n */\nexport default class AccountGeneralized extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n #authFun?: string;\n\n /**\n * @param address - Address of generalized account\n */\n constructor(address: Encoded.AccountAddress) {\n super();\n decode(address);\n this.address = address;\n }\n\n /**\n * @deprecated Use `unsafeSign` method instead\n */\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n return this.unsafeSign();\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async unsafeSign(): Promise<Uint8Array> {\n throw new NotImplementedError(\"Can't sign using generalized account\");\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signMessage(): Promise<Uint8Array> {\n throw new NotImplementedError(\"Can't sign using generalized account\");\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signTypedData(): Promise<Encoded.Signature> {\n throw new NotImplementedError(\"Can't sign using generalized account\");\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signDelegation(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation using generalized account');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1],\n ): Promise<Encoded.Transaction> {\n if (authData == null || onCompiler == null || onNode == null) {\n throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);\n }\n const { callData, sourceCode, args, fee, gasLimit, gasPrice } =\n typeof authData === 'function' ? await authData(tx) : authData;\n\n const authCallData =\n callData ??\n (await (async () => {\n if (this.#authFun == null) {\n const account = await getAccount(this.address, { onNode });\n if (account.kind !== 'generalized') {\n throw new ArgumentError('account kind', 'generalized', account.kind);\n }\n this.#authFun = account.authFun;\n }\n if (this.#authFun == null) {\n throw new InternalError('Account in generalised, but authFun not provided');\n }\n\n if (sourceCode == null || args == null) {\n throw new InvalidAuthDataError('Auth data must contain sourceCode and args or callData.');\n }\n const contract = await Contract.initialize({ onCompiler, onNode, sourceCode });\n return contract._calldata.encode(contract._name, this.#authFun, args);\n })());\n\n const gaMetaTx = await buildTxAsync({\n tag: Tag.GaMetaTx,\n tx: { tag: Tag.SignedTx, encodedTx: decode(tx), signatures: [] },\n gaId: this.address,\n authData: authCallData,\n fee,\n gasLimit,\n gasPrice,\n onNode,\n });\n return buildTx({ tag: Tag.SignedTx, encodedTx: decode(gaMetaTx), signatures: [] });\n }\n}\n"],"mappings":";;;;;AAAA,OAAOA,WAAW,MAAM,WAAW;AACnC,SACEC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB,QACd,oBAAoB;AAC3B,SAASC,MAAM,QAAiB,qBAAqB;AACrD,SAASC,UAAU,QAAQ,aAAa;AACxC,OAAOC,QAAQ,MAAM,yBAAyB;AAC9C,SAASC,YAAY,EAAEC,OAAO,QAAQ,wBAAwB;AAC9D,SAASC,GAAG,QAAQ,4BAA4B;;AAEhD;AACA;AACA;AACA;AAHA,IAAAC,QAAA,oBAAAC,OAAA;AAIA,eAAe,MAAMC,kBAAkB,SAASb,WAAW,CAAC;EAK1D;AACF;AACA;EACEc,WAAWA,CAACC,OAA+B,EAAE;IAC3C,KAAK,CAAC,CAAC;IANTC,0BAAA,OAAAL,QAAQ;IAONN,MAAM,CAACU,OAAO,CAAC;IACf,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;;EAEA;AACF;AACA;EACE;EACA,MAAeE,IAAIA,CAAA,EAAwB;IACzC,OAAO,IAAI,CAACC,UAAU,CAAC,CAAC;EAC1B;;EAEA;EACA,MAAeA,UAAUA,CAAA,EAAwB;IAC/C,MAAM,IAAId,mBAAmB,CAAC,sCAAsC,CAAC;EACvE;;EAEA;EACA,MAAee,WAAWA,CAAA,EAAwB;IAChD,MAAM,IAAIf,mBAAmB,CAAC,sCAAsC,CAAC;EACvE;;EAEA;EACA,MAAegB,aAAaA,CAAA,EAA+B;IACzD,MAAM,IAAIhB,mBAAmB,CAAC,sCAAsC,CAAC;EACvE;;EAEA;EACA,MAAeiB,cAAcA,CAAA,EAA+B;IAC1D,MAAM,IAAIjB,mBAAmB,CAAC,8CAA8C,CAAC;EAC/E;EAEA,MAAekB,eAAeA,CAC5BC,EAAuB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W,CAAC,CAAC;MAC9E,OAAOW,QAAQ,CAACE,SAAS,CAACC,MAAM,CAACH,QAAQ,CAACI,KAAK,EAAET,qBAAA,CAAKvB,QAAQ,EAAb,IAAY,CAAC,EAAEkB,IAAI,CAAC;IACvE,CAAC,EAAE,CAAE;IAEP,MAAMe,QAAQ,GAAG,MAAMpC,YAAY,CAAC;MAClCqC,GAAG,EAAEnC,GAAG,CAACoC,QAAQ;MACjBvB,EAAE,EAAE;QAAEsB,GAAG,EAAEnC,GAAG,CAACqC,QAAQ;QAAEC,SAAS,EAAE3C,MAAM,CAACkB,EAAE,CAAC;QAAE0B,UAAU,EAAE;MAAG,CAAC;MAChEC,IAAI,EAAE,IAAI,CAACnC,OAAO;MAClBS,QAAQ,EAAES,YAAY;MACtBH,GAAG;MACHC,QAAQ;MACRC,QAAQ;MACRN;IACF,CAAC,CAAC;IACF,OAAOjB,OAAO,CAAC;MAAEoC,GAAG,EAAEnC,GAAG,CAACqC,QAAQ;MAAEC,SAAS,EAAE3C,MAAM,CAACuC,QAAQ,CAAC;MAAEK,UAAU,EAAE;IAAG,CAAC,CAAC;EACpF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"Generalized.js","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","buildTxAsync","buildTx","Tag","_authFun","WeakMap","AccountGeneralized","constructor","address","_classPrivateFieldInitSpec","sign","unsafeSign","signMessage","signTypedData","signDelegation","signTransaction","tx","authData","onCompiler","onNode","protocolParameters","callData","sourceCode","args","fee","gasLimit","gasPrice","authCallData","_classPrivateFieldGet","account","kind","_classPrivateFieldSet","authFun","contract","initialize","_calldata","encode","_name","gaMetaTx","tag","GaMetaTx","SignedTx","encodedTx","signatures","gaId"],"sources":["../../src/account/Generalized.ts"],"sourcesContent":["import AccountBase from './Base.js';\nimport {\n ArgumentError,\n InternalError,\n InvalidAuthDataError,\n NotImplementedError,\n} from '../utils/errors.js';\nimport { decode, Encoded } from '../utils/encoder.js';\nimport { getAccount } from '../chain.js';\nimport Contract from '../contract/Contract.js';\nimport { buildTxAsync, buildTx } from '../tx/builder/index.js';\nimport { Tag } from '../tx/builder/constants.js';\n\n/**\n * Generalized account class\n * @category account generalized\n */\nexport default class AccountGeneralized extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n #authFun?: string;\n\n /**\n * @param address - Address of generalized account\n */\n constructor(address: Encoded.AccountAddress) {\n super();\n decode(address);\n this.address = address;\n }\n\n /**\n * @deprecated Use `unsafeSign` method instead\n */\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n return this.unsafeSign();\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async unsafeSign(): Promise<Uint8Array> {\n throw new NotImplementedError(\"Can't sign using generalized account\");\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signMessage(): Promise<Uint8Array> {\n throw new NotImplementedError(\"Can't sign using generalized account\");\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signTypedData(): Promise<Encoded.Signature> {\n throw new NotImplementedError(\"Can't sign using generalized account\");\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signDelegation(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation using generalized account');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n {\n authData,\n onCompiler,\n onNode,\n protocolParameters,\n }: Parameters<AccountBase['signTransaction']>[1],\n ): Promise<Encoded.Transaction> {\n if (authData == null || onCompiler == null || onNode == null) {\n throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);\n }\n const { callData, sourceCode, args, fee, gasLimit, gasPrice } =\n typeof authData === 'function' ? await authData(tx) : authData;\n\n const authCallData =\n callData ??\n (await (async () => {\n if (this.#authFun == null) {\n const account = await getAccount(this.address, { onNode });\n if (account.kind !== 'generalized') {\n throw new ArgumentError('account kind', 'generalized', account.kind);\n }\n this.#authFun = account.authFun;\n }\n if (this.#authFun == null) {\n throw new InternalError('Account in generalised, but authFun not provided');\n }\n\n if (sourceCode == null || args == null) {\n throw new InvalidAuthDataError('Auth data must contain sourceCode and args or callData.');\n }\n const contract = await Contract.initialize({ onCompiler, onNode, sourceCode });\n return contract._calldata.encode(contract._name, this.#authFun, args);\n })());\n\n const gaMetaTx = await buildTxAsync({\n tag: Tag.GaMetaTx,\n tx: { tag: Tag.SignedTx, encodedTx: decode(tx), signatures: [] },\n gaId: this.address,\n authData: authCallData,\n fee,\n gasLimit,\n gasPrice,\n // the wrapping transaction is priced by the same parameters the caller asked the inner one\n // to be built against, `buildTxAsync` requests them from node if not provided\n ...(protocolParameters != null && { protocolParameters }),\n onNode,\n });\n return buildTx({ tag: Tag.SignedTx, encodedTx: decode(gaMetaTx), signatures: [] });\n }\n}\n"],"mappings":";;;;;AAAA,OAAOA,WAAW,MAAM,WAAW;AACnC,SACEC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB,QACd,oBAAoB;AAC3B,SAASC,MAAM,QAAiB,qBAAqB;AACrD,SAASC,UAAU,QAAQ,aAAa;AACxC,OAAOC,QAAQ,MAAM,yBAAyB;AAC9C,SAASC,YAAY,EAAEC,OAAO,QAAQ,wBAAwB;AAC9D,SAASC,GAAG,QAAQ,4BAA4B;;AAEhD;AACA;AACA;AACA;AAHA,IAAAC,QAAA,oBAAAC,OAAA;AAIA,eAAe,MAAMC,kBAAkB,SAASb,WAAW,CAAC;EAK1D;AACF;AACA;EACEc,WAAWA,CAACC,OAA+B,EAAE;IAC3C,KAAK,CAAC,CAAC;IANTC,0BAAA,OAAAL,QAAQ;IAONN,MAAM,CAACU,OAAO,CAAC;IACf,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;;EAEA;AACF;AACA;EACE;EACA,MAAeE,IAAIA,CAAA,EAAwB;IACzC,OAAO,IAAI,CAACC,UAAU,CAAC,CAAC;EAC1B;;EAEA;EACA,MAAeA,UAAUA,CAAA,EAAwB;IAC/C,MAAM,IAAId,mBAAmB,CAAC,sCAAsC,CAAC;EACvE;;EAEA;E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