@aeternity/aepp-sdk 15.0.0 → 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.
package/es/contract/ga.js CHANGED
@@ -96,9 +96,9 @@ async function buildAuthTxHashInternal(transaction, {
96
96
  let payload = hash(concatBuffers([_Buffer.from(nodeNetworkId), decode(transaction)]));
97
97
  if (fee == null) throw new ArgumentError('fee', 'provided (in Ceres)', fee);
98
98
  if (gasPrice == null) throw new ArgumentError('gasPrice', 'provided (in Ceres)', gasPrice);
99
- // the entry checks `gasPrice` against the consensus minimum the same way a transaction does,
100
- // so it needs the same parameters — without them a `gasPrice` correct for the network this
101
- // node runs is rejected whenever that network runs a lower minimum than the SDK release.
99
+ // the entry checks `gasPrice` the same way a transaction does, so it needs the same parameters
100
+ // — without them a `gasPrice` correct for the network this node runs is rejected whenever that
101
+ // network prices a transaction below the SDK release.
102
102
  // Not requested at all when there is nothing to check, so that re-deriving the hash of an
103
103
  // existing transaction needs no round trip and works on a transaction of another network
104
104
  payload = hash(decode(packEntry({
@@ -1 +1 @@
1
- {"version":3,"file":"ga.js","names":["Tag","buildContractIdByContractTx","rebuildUnpackedTx","buildTxAsync","unpackTx","getCachedProtocolParameters","hash","decode","encode","Encoding","ArgumentError","IllegalArgumentError","concatBuffers","Contract","getAccount","sendTransaction","packEntry","EntryTag","serializeAsIsParam","createGeneralizedAccount","authFnName","args","onAccount","onCompiler","onNode","bytecode","aci","sourceCodePath","sourceCode","fileSystem","options","_options$gasLimit","ownerId","address","kind","contract","initialize","tx","_isInternalBuild","tag","GaAttachTx","code","$compile","gasLimit","_estimateGas","callData","_calldata","_name","authFun","transaction","rawTx","contractId","Object","freeze","owner","gaContractId","buildAuthTxHashInternal","fee","gasPrice","protocolParameters","nodeNetworkId","getNodeInfo","payload","_Buffer","from","GaMetaTxAuthData","txHash","TxHash","buildAuthTxHash","buildAuthTxHashByGaMetaTx","txParams","SignedTx","encodedTx","GaMetaTx"],"sources":["../../src/contract/ga.ts"],"sourcesContent":["/**\n * Generalized Account module - routines to use generalized account\n */\n\nimport { Int, Tag } from '../tx/builder/constants.js';\nimport {\n buildContractIdByContractTx,\n rebuildUnpackedTx,\n buildTxAsync,\n BuildTxOptions,\n unpackTx,\n} from '../tx/builder/index.js';\nimport {\n getCachedProtocolParameters,\n ProtocolParametersOption,\n} from '../tx/builder/protocol-parameters.js';\nimport { hash } from '../utils/crypto.js';\nimport { decode, encode, Encoded, Encoding } from '../utils/encoder.js';\nimport { ArgumentError, IllegalArgumentError } from '../utils/errors.js';\nimport { concatBuffers } from '../utils/other.js';\nimport Contract from './Contract.js';\nimport Node from '../Node.js';\nimport { getAccount } from '../chain.js';\nimport { sendTransaction, SendTransactionOptions } from '../send-transaction.js';\nimport CompilerBase from './compiler/Base.js';\nimport { packEntry } from '../tx/builder/entry/index.js';\nimport { EntryTag } from '../tx/builder/entry/constants.js';\nimport { serializeAsIsParam, SerializeAsIsParams } from '../tx/builder/field-types/interface.js';\n\n/**\n * Convert current account to GA\n * @category account generalized\n * @param authFnName - Authorization function name\n * @param args - init arguments\n * @param options - Options\n * @returns General Account Object\n */\nexport async function createGeneralizedAccount(\n authFnName: string,\n args: any[],\n {\n onAccount,\n onCompiler,\n onNode,\n bytecode,\n aci,\n sourceCodePath,\n sourceCode,\n fileSystem,\n ...options\n }: CreateGeneralizedAccountOptions,\n): Promise<\n Readonly<{\n owner: Encoded.AccountAddress;\n transaction: Encoded.TxHash;\n rawTx: Encoded.Transaction;\n gaContractId: Encoded.ContractAddress;\n }>\n> {\n const ownerId = onAccount.address;\n if ((await getAccount(ownerId, { onNode })).kind === 'generalized') {\n throw new IllegalArgumentError(`Account ${ownerId} is already GA`);\n }\n\n const contract = await Contract.initialize<{ init: (...a: any[]) => void }>({\n onAccount,\n onCompiler,\n onNode,\n bytecode,\n aci,\n sourceCodePath,\n sourceCode,\n fileSystem,\n });\n\n const tx = await buildTxAsync({\n _isInternalBuild: true,\n ...options,\n tag: Tag.GaAttachTx,\n onNode,\n code: await contract.$compile(),\n gasLimit: options.gasLimit ?? (await contract._estimateGas('init', args, options)),\n ownerId,\n callData: contract._calldata.encode(contract._name, 'init', args),\n authFun: hash(authFnName),\n });\n const { hash: transaction, rawTx } = await sendTransaction(tx, {\n onNode,\n onAccount,\n onCompiler,\n ...options,\n });\n const contractId = buildContractIdByContractTx(rawTx);\n\n return Object.freeze({\n owner: ownerId,\n transaction,\n rawTx,\n gaContractId: contractId,\n });\n}\n\ninterface CreateGeneralizedAccountOptions\n extends BuildTxOptions<\n Tag.GaAttachTx,\n 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit' | 'onNode'\n >,\n SendTransactionOptions,\n Pick<\n Parameters<typeof Contract.initialize>[0],\n 'bytecode' | 'aci' | 'sourceCodePath' | 'sourceCode' | 'fileSystem'\n > {\n onCompiler: CompilerBase;\n gasLimit?: number;\n}\n\n// the symbol isn't exported, so only `buildAuthTxHashByGaMetaTx` can set it — kept off the public\n// `buildAuthTxHash` signature rather than advertising an option its callers can't provide\nasync function buildAuthTxHashInternal(\n transaction: Encoded.Transaction,\n {\n fee,\n gasPrice,\n onNode,\n protocolParameters,\n ...options\n }: Parameters<typeof buildAuthTxHash>[1] & SerializeAsIsParams,\n): Promise<Buffer> {\n const { nodeNetworkId } = await onNode.getNodeInfo();\n let payload = hash(concatBuffers([Buffer.from(nodeNetworkId), decode(transaction)]));\n if (fee == null) throw new ArgumentError('fee', 'provided (in Ceres)', fee);\n if (gasPrice == null) throw new ArgumentError('gasPrice', 'provided (in Ceres)', gasPrice);\n // the entry checks `gasPrice` against the consensus minimum the same way a transaction does,\n // so it needs the same parameters — without them a `gasPrice` correct for the network this\n // node runs is rejected whenever that network runs a lower minimum than the SDK release.\n // Not requested at all when there is nothing to check, so that re-deriving the hash of an\n // existing transaction needs no round trip and works on a transaction of another network\n payload = hash(\n decode(\n packEntry({\n tag: EntryTag.GaMetaTxAuthData,\n fee,\n gasPrice,\n txHash: encode(payload, Encoding.TxHash),\n ...(options[serializeAsIsParam] === true\n ? { [serializeAsIsParam]: true }\n : {\n protocolParameters: protocolParameters ?? (await getCachedProtocolParameters(onNode)),\n }),\n }),\n ),\n );\n return payload;\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx payload\n * @category account generalized\n * @param transaction - tx-encoded transaction\n * @param options - Options\n * @param options.fee - GaMetaTx fee, required in Ceres\n * @param options.gasPrice - GaMetaTx gasPrice, required in Ceres\n * @param options.onNode - Node to use\n * @param options.protocolParameters - Consensus parameters the `gasPrice` belongs to, requested\n * from node if not provided\n * @returns Transaction hash\n */\nexport async function buildAuthTxHash(\n transaction: Encoded.Transaction,\n {\n fee,\n gasPrice,\n onNode,\n protocolParameters,\n }: { fee?: Int; gasPrice?: Int; onNode: Node } & ProtocolParametersOption,\n): Promise<Buffer> {\n return buildAuthTxHashInternal(transaction, { fee, gasPrice, onNode, protocolParameters });\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx\n * @category account generalized\n * @param transaction - tx-encoded signed GaMeta transaction\n * @param options - Options\n * @param options.onNode - Node to use\n * @returns Transaction hash\n */\nexport async function buildAuthTxHashByGaMetaTx(\n transaction: Encoded.Transaction,\n { onNode }: { onNode: Node },\n): Promise<Buffer> {\n const txParams = unpackTx(transaction, Tag.SignedTx);\n if (txParams.encodedTx.tag !== Tag.GaMetaTx) {\n throw new ArgumentError('transaction', 'to include GaMetaTx', Tag[txParams.encodedTx.tag]);\n }\n return buildAuthTxHashInternal(rebuildUnpackedTx(txParams.encodedTx.tx.encodedTx), {\n fee: txParams.encodedTx.fee,\n gasPrice: txParams.encodedTx.gasPrice,\n onNode,\n // the `gasPrice` of a transaction that already exists, never checked and no parameters\n // requested for it — see `serializeAsIsParam`\n [serializeAsIsParam]: true,\n });\n}\n"],"mappings":";AAAA;AACA;AACA;;AAEA,SAAcA,GAAG,QAAQ,4BAA4B;AACrD,SACEC,2BAA2B,EAC3BC,iBAA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MAAM,IAAI/D,aAAa,CAAC,aAAa,EAAE,qBAAqB,EAAEV,GAAG,CAACsE,QAAQ,CAACE,SAAS,CAACjC,GAAG,CAAC,CAAC;EAC5F;EACA,OAAOiB,uBAAuB,CAACtD,iBAAiB,CAACoE,QAAQ,CAACE,SAAS,CAACnC,EAAE,CAACmC,SAAS,CAAC,EAAE;IACjFf,GAAG,EAAEa,QAAQ,CAACE,SAAS,CAACf,GAAG;IAC3BC,QAAQ,EAAEY,QAAQ,CAACE,SAAS,CAACd,QAAQ;IACrClC,MAAM;IACN;IACA;IACA,CAACN,kBAAkB,GAAG;EACxB,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"ga.js","names":["Tag","buildContractIdByContractTx","rebuildUnpackedTx","buildTxAsync","unpackTx","getCachedProtocolParameters","hash","decode","encode","Encoding","ArgumentError","IllegalArgumentError","concatBuffers","Contract","getAccount","sendTransaction","packEntry","EntryTag","serializeAsIsParam","createGeneralizedAccount","authFnName","args","onAccount","onCompiler","onNode","bytecode","aci","sourceCodePath","sourceCode","fileSystem","options","_options$gasLimit","ownerId","address","kind","contract","initialize","tx","_isInternalBuild","tag","GaAttachTx","code","$compile","gasLimit","_estimateGas","callData","_calldata","_name","authFun","transaction","rawTx","contractId","Object","freeze","owner","gaContractId","buildAuthTxHashInternal","fee","gasPrice","protocolParameters","nodeNetworkId","getNodeInfo","payload","_Buffer","from","GaMetaTxAuthData","txHash","TxHash","buildAuthTxHash","buildAuthTxHashByGaMetaTx","txParams","SignedTx","encodedTx","GaMetaTx"],"sources":["../../src/contract/ga.ts"],"sourcesContent":["/**\n * Generalized Account module - routines to use generalized account\n */\n\nimport { Int, Tag } from '../tx/builder/constants.js';\nimport {\n buildContractIdByContractTx,\n rebuildUnpackedTx,\n buildTxAsync,\n BuildTxOptions,\n unpackTx,\n} from '../tx/builder/index.js';\nimport {\n getCachedProtocolParameters,\n ProtocolParametersOption,\n} from '../tx/builder/protocol-parameters.js';\nimport { hash } from '../utils/crypto.js';\nimport { decode, encode, Encoded, Encoding } from '../utils/encoder.js';\nimport { ArgumentError, IllegalArgumentError } from '../utils/errors.js';\nimport { concatBuffers } from '../utils/other.js';\nimport Contract from './Contract.js';\nimport Node from '../Node.js';\nimport { getAccount } from '../chain.js';\nimport { sendTransaction, SendTransactionOptions } from '../send-transaction.js';\nimport CompilerBase from './compiler/Base.js';\nimport { packEntry } from '../tx/builder/entry/index.js';\nimport { EntryTag } from '../tx/builder/entry/constants.js';\nimport { serializeAsIsParam, SerializeAsIsParams } from '../tx/builder/field-types/interface.js';\n\n/**\n * Convert current account to GA\n * @category account generalized\n * @param authFnName - Authorization function name\n * @param args - init arguments\n * @param options - Options\n * @returns General Account Object\n */\nexport async function createGeneralizedAccount(\n authFnName: string,\n args: any[],\n {\n onAccount,\n onCompiler,\n onNode,\n bytecode,\n aci,\n sourceCodePath,\n sourceCode,\n fileSystem,\n ...options\n }: CreateGeneralizedAccountOptions,\n): Promise<\n Readonly<{\n owner: Encoded.AccountAddress;\n transaction: Encoded.TxHash;\n rawTx: Encoded.Transaction;\n gaContractId: Encoded.ContractAddress;\n }>\n> {\n const ownerId = onAccount.address;\n if ((await getAccount(ownerId, { onNode })).kind === 'generalized') {\n throw new IllegalArgumentError(`Account ${ownerId} is already GA`);\n }\n\n const contract = await Contract.initialize<{ init: (...a: any[]) => void }>({\n onAccount,\n onCompiler,\n onNode,\n bytecode,\n aci,\n sourceCodePath,\n sourceCode,\n fileSystem,\n });\n\n const tx = await buildTxAsync({\n _isInternalBuild: true,\n ...options,\n tag: Tag.GaAttachTx,\n onNode,\n code: await contract.$compile(),\n gasLimit: options.gasLimit ?? (await contract._estimateGas('init', args, options)),\n ownerId,\n callData: contract._calldata.encode(contract._name, 'init', args),\n authFun: hash(authFnName),\n });\n const { hash: transaction, rawTx } = await sendTransaction(tx, {\n onNode,\n onAccount,\n onCompiler,\n ...options,\n });\n const contractId = buildContractIdByContractTx(rawTx);\n\n return Object.freeze({\n owner: ownerId,\n transaction,\n rawTx,\n gaContractId: contractId,\n });\n}\n\ninterface CreateGeneralizedAccountOptions\n extends BuildTxOptions<\n Tag.GaAttachTx,\n 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit' | 'onNode'\n >,\n SendTransactionOptions,\n Pick<\n Parameters<typeof Contract.initialize>[0],\n 'bytecode' | 'aci' | 'sourceCodePath' | 'sourceCode' | 'fileSystem'\n > {\n onCompiler: CompilerBase;\n gasLimit?: number;\n}\n\n// the symbol isn't exported, so only `buildAuthTxHashByGaMetaTx` can set it — kept off the public\n// `buildAuthTxHash` signature rather than advertising an option its callers can't provide\nasync function buildAuthTxHashInternal(\n transaction: Encoded.Transaction,\n {\n fee,\n gasPrice,\n onNode,\n protocolParameters,\n ...options\n }: Parameters<typeof buildAuthTxHash>[1] & SerializeAsIsParams,\n): Promise<Buffer> {\n const { nodeNetworkId } = await onNode.getNodeInfo();\n let payload = hash(concatBuffers([Buffer.from(nodeNetworkId), decode(transaction)]));\n if (fee == null) throw new ArgumentError('fee', 'provided (in Ceres)', fee);\n if (gasPrice == null) throw new ArgumentError('gasPrice', 'provided (in Ceres)', gasPrice);\n // the entry checks `gasPrice` the same way a transaction does, so it needs the same parameters\n // — without them a `gasPrice` correct for the network this node runs is rejected whenever that\n // network prices a transaction below the SDK release.\n // Not requested at all when there is nothing to check, so that re-deriving the hash of an\n // existing transaction needs no round trip and works on a transaction of another network\n payload = hash(\n decode(\n packEntry({\n tag: EntryTag.GaMetaTxAuthData,\n fee,\n gasPrice,\n txHash: encode(payload, Encoding.TxHash),\n ...(options[serializeAsIsParam] === true\n ? { [serializeAsIsParam]: true }\n : {\n protocolParameters: protocolParameters ?? (await getCachedProtocolParameters(onNode)),\n }),\n }),\n ),\n );\n return payload;\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx payload\n * @category account generalized\n * @param transaction - tx-encoded transaction\n * @param options - Options\n * @param options.fee - GaMetaTx fee, required in Ceres\n * @param options.gasPrice - GaMetaTx gasPrice, required in Ceres\n * @param options.onNode - Node to use\n * @param options.protocolParameters - Consensus parameters the `gasPrice` belongs to, requested\n * from node if not provided\n * @returns Transaction hash\n */\nexport async function buildAuthTxHash(\n transaction: Encoded.Transaction,\n {\n fee,\n gasPrice,\n onNode,\n protocolParameters,\n }: { fee?: Int; gasPrice?: Int; onNode: Node } & ProtocolParametersOption,\n): Promise<Buffer> {\n return buildAuthTxHashInternal(transaction, { fee, gasPrice, onNode, protocolParameters });\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx\n * @category account generalized\n * @param transaction - tx-encoded signed GaMeta transaction\n * @param options - Options\n * @param options.onNode - Node to use\n * @returns Transaction hash\n */\nexport async function buildAuthTxHashByGaMetaTx(\n transaction: Encoded.Transaction,\n { onNode }: { onNode: Node },\n): Promise<Buffer> {\n const txParams = unpackTx(transaction, Tag.SignedTx);\n if (txParams.encodedTx.tag !== Tag.GaMetaTx) {\n throw new ArgumentError('transaction', 'to include GaMetaTx', Tag[txParams.encodedTx.tag]);\n }\n return buildAuthTxHashInternal(rebuildUnpackedTx(txParams.encodedTx.tx.encodedTx), {\n fee: txParams.encodedTx.fee,\n gasPrice: txParams.encodedTx.gasPrice,\n onNode,\n // the `gasPrice` of a transaction that already exists, never checked and no parameters\n // requested for it — see `serializeAsIsParam`\n [serializeAsIsParam]: true,\n });\n}\n"],"mappings":";AAAA;AACA;AACA;;AAEA,SAAcA,GAAG,QAAQ,4BAA4B;AACrD,SACEC,2BAA2B,EAC3BC,iBAAiB,EACjBC,YAAY,EAEZC,QAAQ,QACH,wBAAwB;AAC/B,SACEC,2BAA2B,QAEtB,sCAAsC;AAC7C,SAASC,IAAI,QAAQ,oBAAoB;AACzC,SAASC,MAAM,EAAEC,MAAM,EAAWC,QAAQ,QAAQ,qBAAqB;AACvE,SAASC,aAAa,EAAEC,oBAAoB,QAAQ,oBAAoB;AACxE,SAASC,aAAa,QAAQ,mBAAmB;AACjD,OAAOC,QAAQ,M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AAQ,EAAEY,QAAQ,CAACE,SAAS,CAACd,QAAQ;IACrClC,MAAM;IACN;IACA;IACA,CAACN,kBAAkB,GAAG;EACxB,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -33,7 +33,7 @@ export { buildContractId as encodeContractAddress } from './tx/builder/helpers.j
33
33
  export { isName as isNameValid } from './tx/builder/helpers.js';
34
34
  export { MAX_AUTH_FUN_GAS, MIN_GAS_PRICE, NAME_FEE_MULTIPLIER, NAME_FEE_BID_INCREMENT, NAME_BID_TIMEOUT_BLOCKS, NAME_MAX_LENGTH_FEE, NAME_BID_RANGES, ConsensusProtocolVersion, VmVersion, AbiVersion, Tag, DRY_RUN_ACCOUNT, } from './tx/builder/constants.js';
35
35
  export type { Int, AensName } from './tx/builder/constants.js';
36
- export { defaultProtocolParameters, getCachedProtocolParameters, } from './tx/builder/protocol-parameters.js';
36
+ export { defaultProtocolParameters, getCachedProtocolParameters, getFloorGasPrice, } from './tx/builder/protocol-parameters.js';
37
37
  export type { ProtocolParameters, ProtocolParametersOption, } from './tx/builder/protocol-parameters.js';
38
38
  export { ORACLE_TTL_TYPES } from './tx/builder/schema.js';
39
39
  export { DelegationTag } from './tx/builder/delegation/schema.js';
@@ -31,7 +31,7 @@ export { buildContractId as encodeContractAddress } from './tx/builder/helpers.j
31
31
  */
32
32
  export { isName as isNameValid } from './tx/builder/helpers.js';
33
33
  export { MAX_AUTH_FUN_GAS, MIN_GAS_PRICE, NAME_FEE_MULTIPLIER, NAME_FEE_BID_INCREMENT, NAME_BID_TIMEOUT_BLOCKS, NAME_MAX_LENGTH_FEE, NAME_BID_RANGES, ConsensusProtocolVersion, VmVersion, AbiVersion, Tag, DRY_RUN_ACCOUNT } from './tx/builder/constants.js';
34
- export { defaultProtocolParameters, getCachedProtocolParameters } from './tx/builder/protocol-parameters.js';
34
+ export { defaultProtocolParameters, getCachedProtocolParameters, getFloorGasPrice } from './tx/builder/protocol-parameters.js';
35
35
  // TODO: move to constants
36
36
  export { ORACLE_TTL_TYPES } from './tx/builder/schema.js';
37
37
  export { DelegationTag } from './tx/builder/delegation/schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser.js","names":["_getPollInterval","getHeight","poll","awaitHeight","waitForTxConfirm","getAccount","getBalance","getCurrentGeneration","getGeneration","getMicroBlockTransactions","getKeyBlock","getMicroBlockHeader","txDryRun","getContractByteCode","getContract","getName","resolveName","InvalidTxError","sendTransaction","isAddressValid","ensureEncoded","isEncoded","genSalt","encodeUnsigned","hash","verifySignature","hashMessage","verifyMessageSignature","verify","messageToHash","verifyMessage","signJwt","unpackJwt","verifyJwt","isJwt","ensureJwt","toBytes","buildTx","buildTxAsync","buildTxHash","rebuildUnpackedTx","unpackTx","buildContractIdByContractTx","buildContractId","oracleQueryId","produceNameId","commitmentHash","readInt","isName","ensureName","getDefaultPointerKey","getMinimumNameFee","computeBidFee","computeAuctionEndBlock","isAuctionName","encodeContractAddress","isNameValid","MAX_AUTH_FUN_GAS","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_RANGES","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag","DRY_RUN_ACCOUNT","defaultProtocolParameters","getCachedProtocolParameters","ORACLE_TTL_TYPES","DelegationTag","packDelegation","unpackDelegation","EntryTag","CallReturnType","packEntry","unpackEntry","getExecutionCost","getExecutionCostBySignedTx","getExecutionCostUsingNode","default","getTransactionSignerAddress","AE_AMOUNT_FORMATS","formatAmount","toAe","toAettos","prefixedAmount","encode","decode","Encoding","Encoded","hashTypedData","hashDomain","hashJson","Name","Contract","Oracle","OracleClient","spend","transferFunds","payForTransaction","createGeneralizedAccount","buildAuthTxHash","buildAuthTxHashByGaMetaTx","AeSdkMethods","AeSdkBase","AeSdk","AeSdkAepp","WalletConnectorFrame","WalletConnectorFrameWithNode","AeSdkWallet","Node","verifyTransaction","AccountBase","AccountMemory","MemoryAccount","AccountMnemonicFactory","AccountGeneralized","AccountLedger","AccountLedgerFactory","AccountMetamask","AccountMetamaskFactory","CompilerBase","CompilerHttp","Channel","MiddlewareSubscriber","MiddlewareSubscriberError","MiddlewareSubscriberDisconnected","Middleware","MiddlewarePageMissed","connectionProxy","MESSAGE_DIRECTION","WALLET_TYPE","SUBSCRIPTION_TYPES","METHODS","RPC_STATUS","RpcError","RpcInvalidTransactionError","RpcRejectedByUserError","RpcUnsupportedProtocolError","RpcConnectionDenyError","RpcNotAuthorizeError","RpcPermissionDenyError","RpcInternalError","RpcMethodNotFoundError","RpcNoNetworkById","walletDetector","BrowserRuntimeConnection","BrowserWindowMessageConnection","BaseError","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","IllegalArgumentError","ArgumentCountMismatchError","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","TxTimedOutError","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","LogicError","InternalError","UnexpectedTsError","UnavailableAccountError","AensPointerContextError","InsufficientNameFeeError","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","UnAuthorizedAccountError","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","ChannelIncomingMessageError","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","DuplicateContractError","InactiveContractError","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","NoSuchContractFunctionError","NotPayableFunctionError","MissingEventDefinitionError","AmbiguousEventDefinitionError","InvalidChecksumError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","UnknownPathNibbleError","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","PrefixNotFoundError","SchemaNotFoundError","TagNotFoundError","TxNotInChainError","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError"],"sources":["../src/index-browser.ts"],"sourcesContent":["export {\n _getPollInterval,\n getHeight,\n poll,\n awaitHeight,\n waitForTxConfirm,\n getAccount,\n getBalance,\n getCurrentGeneration,\n getGeneration,\n getMicroBlockTransactions,\n getKeyBlock,\n getMicroBlockHeader,\n txDryRun,\n getContractByteCode,\n getContract,\n getName,\n resolveName,\n} from './chain.js';\nexport { InvalidTxError, sendTransaction } from './send-transaction.js';\nexport {\n isAddressValid,\n ensureEncoded,\n isEncoded,\n genSalt,\n encodeUnsigned,\n hash,\n verifySignature,\n hashMessage,\n verifyMessageSignature,\n} from './utils/crypto.js';\n/**\n * @category utils\n * @deprecated use {@link verifySignature} instead\n */\nexport { verifySignature as verify } from './utils/crypto.js';\n/**\n * @deprecated use {@link hashMessage} instead\n * @category utils\n */\nexport { hashMessage as messageToHash } from './utils/crypto.js';\n/**\n * @deprecated use {@link verifyMessageSignature} instead\n * @category utils\n */\nexport { verifyMessageSignature as verifyMessage } from './utils/crypto.js';\nexport { signJwt, unpackJwt, verifyJwt, isJwt, ensureJwt } from './utils/jwt.js';\nexport type { Jwt } from './utils/jwt.js';\nexport { toBytes } from './utils/bytes.js';\nexport {\n buildTx,\n buildTxAsync,\n buildTxHash,\n rebuildUnpackedTx,\n unpackTx,\n buildContractIdByContractTx,\n} from './tx/builder/index.js';\nexport {\n buildContractId,\n oracleQueryId,\n produceNameId,\n commitmentHash,\n readInt,\n isName,\n ensureName,\n getDefaultPointerKey,\n getMinimumNameFee,\n computeBidFee,\n computeAuctionEndBlock,\n isAuctionName,\n} from './tx/builder/helpers.js';\n/**\n * @category contract\n * @deprecated use {@link buildContractId} instead\n */\nexport { buildContractId as encodeContractAddress } from './tx/builder/helpers.js';\n/**\n * @category AENS\n * @deprecated use {@link isName} instead\n */\nexport { isName as isNameValid } from './tx/builder/helpers.js';\nexport {\n MAX_AUTH_FUN_GAS,\n MIN_GAS_PRICE,\n NAME_FEE_MULTIPLIER,\n NAME_FEE_BID_INCREMENT,\n NAME_BID_TIMEOUT_BLOCKS,\n NAME_MAX_LENGTH_FEE,\n NAME_BID_RANGES,\n ConsensusProtocolVersion,\n VmVersion,\n AbiVersion,\n Tag,\n DRY_RUN_ACCOUNT,\n} from './tx/builder/constants.js';\nexport type { Int, AensName } from './tx/builder/constants.js';\nexport {\n defaultProtocolParameters,\n getCachedProtocolParameters,\n} from './tx/builder/protocol-parameters.js';\nexport type {\n ProtocolParameters,\n ProtocolParametersOption,\n} from './tx/builder/protocol-parameters.js';\n// TODO: move to constants\nexport { ORACLE_TTL_TYPES } from './tx/builder/schema.js';\nexport { DelegationTag } from './tx/builder/delegation/schema.js';\nexport { packDelegation, unpackDelegation } from './tx/builder/delegation/index.js';\nexport { EntryTag, CallReturnType } from './tx/builder/entry/constants.js';\nexport { packEntry, unpackEntry } from './tx/builder/entry/index.js';\nexport {\n getExecutionCost,\n getExecutionCostBySignedTx,\n getExecutionCostUsingNode,\n} from './tx/execution-cost.js';\nexport { default as getTransactionSignerAddress } from './tx/transaction-signer.js';\nexport {\n AE_AMOUNT_FORMATS,\n formatAmount,\n toAe,\n toAettos,\n prefixedAmount,\n} from './utils/amount-formatter.js';\nexport { encode, decode, Encoding, Encoded } from './utils/encoder.js';\nexport { hashTypedData, hashDomain, hashJson } from './utils/typed-data.js';\nexport { default as Name } from './aens.js';\nexport { default as Contract } from './contract/Contract.js';\nexport type { ContractMethodsBase } from './contract/Contract.js';\nexport { default as Oracle } from './oracle/Oracle.js';\nexport { default as OracleClient } from './oracle/OracleClient.js';\nexport { spend, transferFunds, payForTransaction } from './spend.js';\nexport {\n createGeneralizedAccount,\n buildAuthTxHash,\n buildAuthTxHashByGaMetaTx,\n} from './contract/ga.js';\n\nexport { default as AeSdkMethods } from './AeSdkMethods.js';\nexport { default as AeSdkBase } from './AeSdkBase.js';\nexport { default as AeSdk } from './AeSdk.js';\nexport { default as AeSdkAepp } from './AeSdkAepp.js';\nexport { default as WalletConnectorFrame } from './aepp-wallet-communication/WalletConnectorFrame.js';\nexport { default as WalletConnectorFrameWithNode } from './aepp-wallet-communication/WalletConnectorFrameWithNode.js';\nexport { default as AeSdkWallet } from './AeSdkWallet.js';\nexport { default as Node } from './Node.js';\nexport { default as verifyTransaction } from './tx/validator.js';\nexport { default as AccountBase } from './account/Base.js';\nexport { default as AccountMemory } from './account/Memory.js';\n/**\n * @deprecated Use {@link AccountMemory} instead\n * @category account\n */\nexport { default as MemoryAccount } from './account/Memory.js';\nexport { default as AccountMnemonicFactory } from './account/MnemonicFactory.js';\nexport { default as AccountGeneralized } from './account/Generalized.js';\nexport { default as AccountLedger } from './account/Ledger.js';\nexport { default as AccountLedgerFactory } from './account/LedgerFactory.js';\nexport { default as AccountMetamask } from './account/Metamask.js';\nexport { default as AccountMetamaskFactory } from './account/MetamaskFactory.js';\nexport { default as CompilerBase } from './contract/compiler/Base.js';\nexport { default as CompilerHttp } from './contract/compiler/Http.js';\nexport { default as Channel } from './channel/Contract.js';\nexport {\n default as MiddlewareSubscriber,\n MiddlewareSubscriberError,\n MiddlewareSubscriberDisconnected,\n} from './MiddlewareSubscriber.js';\nexport { default as Middleware } from './Middleware.js';\nexport { MiddlewarePageMissed } from './utils/MiddlewarePage.js';\n\nexport { default as connectionProxy } from './aepp-wallet-communication/connection-proxy.js';\nexport {\n MESSAGE_DIRECTION,\n WALLET_TYPE,\n SUBSCRIPTION_TYPES,\n METHODS,\n RPC_STATUS,\n RpcError,\n RpcInvalidTransactionError,\n RpcRejectedByUserError,\n RpcUnsupportedProtocolError,\n RpcConnectionDenyError,\n RpcNotAuthorizeError,\n RpcPermissionDenyError,\n RpcInternalError,\n RpcMethodNotFoundError,\n RpcNoNetworkById,\n} from './aepp-wallet-communication/schema.js';\nexport { default as walletDetector } from './aepp-wallet-communication/wallet-detector.js';\nexport { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime.js';\nexport { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage.js';\nexport {\n BaseError,\n AccountError,\n AensError,\n AeppError,\n ChannelError,\n CompilerError,\n ContractError,\n CryptographyError,\n NodeError,\n TransactionError,\n WalletError,\n ArgumentError,\n IllegalArgumentError,\n ArgumentCountMismatchError,\n InsufficientBalanceError,\n MissingParamError,\n NoSerializerFoundError,\n RequestTimedOutError,\n TxTimedOutError,\n TypeError,\n UnsupportedPlatformError,\n UnsupportedProtocolError,\n NotImplementedError,\n UnsupportedVersionError,\n LogicError,\n InternalError,\n UnexpectedTsError,\n UnavailableAccountError,\n AensPointerContextError,\n InsufficientNameFeeError,\n InvalidAensNameError,\n InvalidRpcMessageError,\n MissingCallbackError,\n UnAuthorizedAccountError,\n UnknownRpcClientError,\n UnsubscribedAccountError,\n ChannelCallError,\n ChannelConnectionError,\n ChannelPingTimedOutError,\n UnexpectedChannelMessageError,\n ChannelIncomingMessageError,\n UnknownChannelStateError,\n InvalidAuthDataError,\n BytecodeMismatchError,\n DuplicateContractError,\n InactiveContractError,\n InvalidMethodInvocationError,\n MissingContractAddressError,\n MissingContractDefError,\n MissingFunctionNameError,\n NodeInvocationError,\n NoSuchContractFunctionError,\n NotPayableFunctionError,\n MissingEventDefinitionError,\n AmbiguousEventDefinitionError,\n InvalidChecksumError,\n MerkleTreeHashMismatchError,\n MissingNodeInTreeError,\n UnknownNodeLengthError,\n UnknownPathNibbleError,\n DuplicateNodeError,\n NodeNotFoundError,\n DecodeError,\n PayloadLengthError,\n DryRunError,\n IllegalBidFeeError,\n InvalidSignatureError,\n PrefixNotFoundError,\n SchemaNotFoundError,\n TagNotFoundError,\n TxNotInChainError,\n AlreadyConnectedError,\n NoWalletConnectedError,\n RpcConnectionError,\n} from './utils/errors.js';\n"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,oBAAoB,EACpBC,aAAa,EACbC,yBAAyB,EACzBC,WAA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sB,EACtBC,kBAAkB,QACb,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"index-browser.js","names":["_getPollInterval","getHeight","poll","awaitHeight","waitForTxConfirm","getAccount","getBalance","getCurrentGeneration","getGeneration","getMicroBlockTransactions","getKeyBlock","getMicroBlockHeader","txDryRun","getContractByteCode","getContract","getName","resolveName","InvalidTxError","sendTransaction","isAddressValid","ensureEncoded","isEncoded","genSalt","encodeUnsigned","hash","verifySignature","hashMessage","verifyMessageSignature","verify","messageToHash","verifyMessage","signJwt","unpackJwt","verifyJwt","isJwt","ensureJwt","toBytes","buildTx","buildTxAsync","buildTxHash","rebuildUnpackedTx","unpackTx","buildContractIdByContractTx","buildContractId","oracleQueryId","produceNameId","commitmentHash","readInt","isName","ensureName","getDefaultPointerKey","getMinimumNameFee","computeBidFee","computeAuctionEndBlock","isAuctionName","encodeContractAddress","isNameValid","MAX_AUTH_FUN_GAS","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_RANGES","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag","DRY_RUN_ACCOUNT","defaultProtocolParameters","getCachedProtocolParameters","getFloorGasPrice","ORACLE_TTL_TYPES","DelegationTag","packDelegation","unpackDelegation","EntryTag","CallReturnType","packEntry","unpackEntry","getExecutionCost","getExecutionCostBySignedTx","getExecutionCostUsingNode","default","getTransactionSignerAddress","AE_AMOUNT_FORMATS","formatAmount","toAe","toAettos","prefixedAmount","encode","decode","Encoding","Encoded","hashTypedData","hashDomain","hashJson","Name","Contract","Oracle","OracleClient","spend","transferFunds","payForTransaction","createGeneralizedAccount","buildAuthTxHash","buildAuthTxHashByGaMetaTx","AeSdkMethods","AeSdkBase","AeSdk","AeSdkAepp","WalletConnectorFrame","WalletConnectorFrameWithNode","AeSdkWallet","Node","verifyTransaction","AccountBase","AccountMemory","MemoryAccount","AccountMnemonicFactory","AccountGeneralized","AccountLedger","AccountLedgerFactory","AccountMetamask","AccountMetamaskFactory","CompilerBase","CompilerHttp","Channel","MiddlewareSubscriber","MiddlewareSubscriberError","MiddlewareSubscriberDisconnected","Middleware","MiddlewarePageMissed","connectionProxy","MESSAGE_DIRECTION","WALLET_TYPE","SUBSCRIPTION_TYPES","METHODS","RPC_STATUS","RpcError","RpcInvalidTransactionError","RpcRejectedByUserError","RpcUnsupportedProtocolError","RpcConnectionDenyError","RpcNotAuthorizeError","RpcPermissionDenyError","RpcInternalError","RpcMethodNotFoundError","RpcNoNetworkById","walletDetector","BrowserRuntimeConnection","BrowserWindowMessageConnection","BaseError","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","IllegalArgumentError","ArgumentCountMismatchError","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","TxTimedOutError","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","LogicError","InternalError","UnexpectedTsError","UnavailableAccountError","AensPointerContextError","InsufficientNameFeeError","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","UnAuthorizedAccountError","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","ChannelIncomingMessageError","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","DuplicateContractError","InactiveContractError","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","NoSuchContractFunctionError","NotPayableFunctionError","MissingEventDefinitionError","AmbiguousEventDefinitionError","InvalidChecksumError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","UnknownPathNibbleError","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","PrefixNotFoundError","SchemaNotFoundError","TagNotFoundError","TxNotInChainError","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError"],"sources":["../src/index-browser.ts"],"sourcesContent":["export {\n _getPollInterval,\n getHeight,\n poll,\n awaitHeight,\n waitForTxConfirm,\n getAccount,\n getBalance,\n getCurrentGeneration,\n getGeneration,\n getMicroBlockTransactions,\n getKeyBlock,\n getMicroBlockHeader,\n txDryRun,\n getContractByteCode,\n getContract,\n getName,\n resolveName,\n} from './chain.js';\nexport { InvalidTxError, sendTransaction } from './send-transaction.js';\nexport {\n isAddressValid,\n ensureEncoded,\n isEncoded,\n genSalt,\n encodeUnsigned,\n hash,\n verifySignature,\n hashMessage,\n verifyMessageSignature,\n} from './utils/crypto.js';\n/**\n * @category utils\n * @deprecated use {@link verifySignature} instead\n */\nexport { verifySignature as verify } from './utils/crypto.js';\n/**\n * @deprecated use {@link hashMessage} instead\n * @category utils\n */\nexport { hashMessage as messageToHash } from './utils/crypto.js';\n/**\n * @deprecated use {@link verifyMessageSignature} instead\n * @category utils\n */\nexport { verifyMessageSignature as verifyMessage } from './utils/crypto.js';\nexport { signJwt, unpackJwt, verifyJwt, isJwt, ensureJwt } from './utils/jwt.js';\nexport type { Jwt } from './utils/jwt.js';\nexport { toBytes } from './utils/bytes.js';\nexport {\n buildTx,\n buildTxAsync,\n buildTxHash,\n rebuildUnpackedTx,\n unpackTx,\n buildContractIdByContractTx,\n} from './tx/builder/index.js';\nexport {\n buildContractId,\n oracleQueryId,\n produceNameId,\n commitmentHash,\n readInt,\n isName,\n ensureName,\n getDefaultPointerKey,\n getMinimumNameFee,\n computeBidFee,\n computeAuctionEndBlock,\n isAuctionName,\n} from './tx/builder/helpers.js';\n/**\n * @category contract\n * @deprecated use {@link buildContractId} instead\n */\nexport { buildContractId as encodeContractAddress } from './tx/builder/helpers.js';\n/**\n * @category AENS\n * @deprecated use {@link isName} instead\n */\nexport { isName as isNameValid } from './tx/builder/helpers.js';\nexport {\n MAX_AUTH_FUN_GAS,\n MIN_GAS_PRICE,\n NAME_FEE_MULTIPLIER,\n NAME_FEE_BID_INCREMENT,\n NAME_BID_TIMEOUT_BLOCKS,\n NAME_MAX_LENGTH_FEE,\n NAME_BID_RANGES,\n ConsensusProtocolVersion,\n VmVersion,\n AbiVersion,\n Tag,\n DRY_RUN_ACCOUNT,\n} from './tx/builder/constants.js';\nexport type { Int, AensName } from './tx/builder/constants.js';\nexport {\n defaultProtocolParameters,\n getCachedProtocolParameters,\n getFloorGasPrice,\n} from './tx/builder/protocol-parameters.js';\nexport type {\n ProtocolParameters,\n ProtocolParametersOption,\n} from './tx/builder/protocol-parameters.js';\n// TODO: move to constants\nexport { ORACLE_TTL_TYPES } from './tx/builder/schema.js';\nexport { DelegationTag } from './tx/builder/delegation/schema.js';\nexport { packDelegation, unpackDelegation } from './tx/builder/delegation/index.js';\nexport { EntryTag, CallReturnType } from './tx/builder/entry/constants.js';\nexport { packEntry, unpackEntry } from './tx/builder/entry/index.js';\nexport {\n getExecutionCost,\n getExecutionCostBySignedTx,\n getExecutionCostUsingNode,\n} from './tx/execution-cost.js';\nexport { default as getTransactionSignerAddress } from './tx/transaction-signer.js';\nexport {\n AE_AMOUNT_FORMATS,\n formatAmount,\n toAe,\n toAettos,\n prefixedAmount,\n} from './utils/amount-formatter.js';\nexport { encode, decode, Encoding, Encoded } from './utils/encoder.js';\nexport { hashTypedData, hashDomain, hashJson } from './utils/typed-data.js';\nexport { default as Name } from './aens.js';\nexport { default as Contract } from './contract/Contract.js';\nexport type { ContractMethodsBase } from './contract/Contract.js';\nexport { default as Oracle } from './oracle/Oracle.js';\nexport { default as OracleClient } from './oracle/OracleClient.js';\nexport { spend, transferFunds, payForTransaction } from './spend.js';\nexport {\n createGeneralizedAccount,\n buildAuthTxHash,\n buildAuthTxHashByGaMetaTx,\n} from './contract/ga.js';\n\nexport { default as AeSdkMethods } from './AeSdkMethods.js';\nexport { default as AeSdkBase } from './AeSdkBase.js';\nexport { default as AeSdk } from './AeSdk.js';\nexport { default as AeSdkAepp } from './AeSdkAepp.js';\nexport { default as WalletConnectorFrame } from './aepp-wallet-communication/WalletConnectorFrame.js';\nexport { default as WalletConnectorFrameWithNode } from './aepp-wallet-communication/WalletConnectorFrameWithNode.js';\nexport { default as AeSdkWallet } from './AeSdkWallet.js';\nexport { default as Node } from './Node.js';\nexport { default as verifyTransaction } from './tx/validator.js';\nexport { default as AccountBase } from './account/Base.js';\nexport { default as AccountMemory } from './account/Memory.js';\n/**\n * @deprecated Use {@link AccountMemory} instead\n * @category account\n */\nexport { default as MemoryAccount } from './account/Memory.js';\nexport { default as AccountMnemonicFactory } from './account/MnemonicFactory.js';\nexport { default as AccountGeneralized } from './account/Generalized.js';\nexport { default as AccountLedger } from './account/Ledger.js';\nexport { default as AccountLedgerFactory } from './account/LedgerFactory.js';\nexport { default as AccountMetamask } from './account/Metamask.js';\nexport { default as AccountMetamaskFactory } from './account/MetamaskFactory.js';\nexport { default as CompilerBase } from './contract/compiler/Base.js';\nexport { default as CompilerHttp } from './contract/compiler/Http.js';\nexport { default as Channel } from './channel/Contract.js';\nexport {\n default as MiddlewareSubscriber,\n MiddlewareSubscriberError,\n MiddlewareSubscriberDisconnected,\n} from './MiddlewareSubscriber.js';\nexport { default as Middleware } from './Middleware.js';\nexport { MiddlewarePageMissed } from './utils/MiddlewarePage.js';\n\nexport { default as connectionProxy } from './aepp-wallet-communication/connection-proxy.js';\nexport {\n MESSAGE_DIRECTION,\n WALLET_TYPE,\n SUBSCRIPTION_TYPES,\n METHODS,\n RPC_STATUS,\n RpcError,\n RpcInvalidTransactionError,\n RpcRejectedByUserError,\n RpcUnsupportedProtocolError,\n RpcConnectionDenyError,\n RpcNotAuthorizeError,\n RpcPermissionDenyError,\n RpcInternalError,\n RpcMethodNotFoundError,\n RpcNoNetworkById,\n} from './aepp-wallet-communication/schema.js';\nexport { default as walletDetector } from './aepp-wallet-communication/wallet-detector.js';\nexport { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime.js';\nexport { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage.js';\nexport {\n BaseError,\n AccountError,\n AensError,\n AeppError,\n ChannelError,\n CompilerError,\n ContractError,\n CryptographyError,\n NodeError,\n TransactionError,\n WalletError,\n ArgumentError,\n IllegalArgumentError,\n ArgumentCountMismatchError,\n InsufficientBalanceError,\n MissingParamError,\n NoSerializerFoundError,\n RequestTimedOutError,\n TxTimedOutError,\n TypeError,\n UnsupportedPlatformError,\n UnsupportedProtocolError,\n NotImplementedError,\n UnsupportedVersionError,\n LogicError,\n InternalError,\n UnexpectedTsError,\n UnavailableAccountError,\n AensPointerContextError,\n InsufficientNameFeeError,\n InvalidAensNameError,\n InvalidRpcMessageError,\n MissingCallbackError,\n UnAuthorizedAccountError,\n UnknownRpcClientError,\n UnsubscribedAccountError,\n ChannelCallError,\n ChannelConnectionError,\n ChannelPingTimedOutError,\n UnexpectedChannelMessageError,\n ChannelIncomingMessageError,\n UnknownChannelStateError,\n InvalidAuthDataError,\n BytecodeMismatchError,\n DuplicateContractError,\n InactiveContractError,\n InvalidMethodInvocationError,\n MissingContractAddressError,\n MissingContractDefError,\n MissingFunctionNameError,\n NodeInvocationError,\n NoSuchContractFunctionError,\n NotPayableFunctionError,\n MissingEventDefinitionError,\n AmbiguousEventDefinitionError,\n InvalidChecksumError,\n MerkleTreeHashMismatchError,\n MissingNodeInTreeError,\n UnknownNodeLengthError,\n UnknownPathNibbleError,\n DuplicateNodeError,\n NodeNotFoundError,\n DecodeError,\n PayloadLengthError,\n DryRunError,\n IllegalBidFeeError,\n InvalidSignatureError,\n PrefixNotFoundError,\n SchemaNotFoundError,\n TagNotFoundError,\n TxNotInChainError,\n AlreadyConnectedError,\n NoWalletConnectedError,\n RpcConnectionError,\n} from './utils/errors.js';\n"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,oBAAoB,EACpBC,aAAa,EACbC,yBAAyB,EACzBC,WAAW,EACXC,m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,sBAAsB,EACtBC,kBAAkB,QACb,mBAAmB","ignoreList":[]}
@@ -28,8 +28,9 @@ export type AensName = `${string}.chain`;
28
28
  * The consensus minimum gas price as it was at the moment of the SDK release.
29
29
  * @category transaction builder
30
30
  * @deprecated a node may run another minimum gas price, and this constant is wrong on it. Use
31
- * `(await getCachedProtocolParameters(node)).minGasPrice` for the value the connected node
32
- * reports, or `defaultProtocolParameters.minGasPrice` for this one.
31
+ * `getFloorGasPrice(await getCachedProtocolParameters(node))` to price a transaction for the
32
+ * connected node — the consensus minimum it reports is below what its miner accepts on a public
33
+ * network. `defaultProtocolParameters.minGasPrice` is this constant.
33
34
  */
34
35
  export declare const MIN_GAS_PRICE = 1000000000;
35
36
  /**
@@ -31,8 +31,9 @@ export const MAX_AUTH_FUN_GAS = 50000;
31
31
  * The consensus minimum gas price as it was at the moment of the SDK release.
32
32
  * @category transaction builder
33
33
  * @deprecated a node may run another minimum gas price, and this constant is wrong on it. Use
34
- * `(await getCachedProtocolParameters(node)).minGasPrice` for the value the connected node
35
- * reports, or `defaultProtocolParameters.minGasPrice` for this one.
34
+ * `getFloorGasPrice(await getCachedProtocolParameters(node))` to price a transaction for the
35
+ * connected node — the consensus minimum it reports is below what its miner accepts on a public
36
+ * network. `defaultProtocolParameters.minGasPrice` is this constant.
36
37
  */
37
38
  export const MIN_GAS_PRICE = 1e9; // TODO: don't use number for ae
38
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["BigNumber","mapObject","DRY_RUN_ACCOUNT","pub","amount","MAX_AUTH_FUN_GAS","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_RANGES","key","value","times","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other.js';\n\n/**\n * @category transaction builder\n */\nexport const DRY_RUN_ACCOUNT = {\n pub: 'ak_11111111111111111111111111111111273Yts',\n amount: 100000000000000000000000000000000000n,\n} as const;\n\n/**\n * The maximum gas of a generalized account authentication function as it was at the moment of the\n * SDK release. It is a node policy setting rather than a consensus parameter.\n * @category account generalized\n * @deprecated the transaction builder ensures that gas doesn't exceed the maximum by itself, and a\n * node may accept another maximum than this constant. Use\n * `(await getCachedProtocolParameters(node)).maxAuthFunGas` for the value the connected node\n * reports, or `defaultProtocolParameters.maxAuthFunGas` for this one.\n */\nexport const MAX_AUTH_FUN_GAS = 50000;\n/**\n * @category utils\n */\nexport type Int = number | string | BigNumber;\n/**\n * @category AENS\n */\nexport type AensName = `${string}.chain`;\n/**\n * The consensus minimum gas price as it was at the moment of the SDK release.\n * @category transaction builder\n * @deprecated a node may run another minimum gas price, and this constant is wrong on it. Use\n * `(await getCachedProtocolParameters(node)).minGasPrice` for the value the connected node\n * reports, or `defaultProtocolParameters.minGasPrice` for this one.\n */\nexport const MIN_GAS_PRICE = 1e9; // TODO: don't use number for ae\n/**\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67}\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_FEE_MULTIPLIER = 1e14;\n/**\n * The next bid should be at least 5% bigger than the previous one\n * @category AENS\n * @deprecated use {@link computeBidFee} instead\n */\nexport const NAME_FEE_BID_INCREMENT = 0.05;\n/**\n * Approximately 1 day\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272}\n * @deprecated use {@link computeAuctionEndBlock} instead\n */\nexport const NAME_BID_TIMEOUT_BLOCKS = 480;\n/**\n * This is the max length for a domain that requires a base fee to be paid\n * @category AENS\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_MAX_LENGTH_FEE = 31;\n/**\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290}\n * @see {@link https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times}\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_BID_RANGES = mapObject(\n {\n 31: 3,\n 30: 5,\n 29: 8,\n 28: 13,\n 27: 21,\n 26: 34,\n 25: 55,\n 24: 89,\n 23: 144,\n 22: 233,\n 21: 377,\n 20: 610,\n 19: 987,\n 18: 1597,\n 17: 2584,\n 16: 4181,\n 15: 6765,\n 14: 10946,\n 13: 17711,\n 12: 28657,\n 11: 46368,\n 10: 75025,\n 9: 121393,\n 8: 196418,\n 7: 317811,\n 6: 514229,\n 5: 832040,\n 4: 1346269,\n 3: 2178309,\n 2: 3524578,\n 1: 5702887,\n },\n ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)],\n);\n\n/**\n * @category chain\n */\nexport enum ConsensusProtocolVersion {\n Ceres = 6,\n Arcus = 7,\n}\n\n/**\n * @category contract\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}\n */\nexport enum VmVersion {\n NoVm = 0,\n Sophia = 1,\n SophiaImprovementsMinerva = 3,\n SophiaImprovementsFortuna = 4,\n Fate = 5,\n SophiaImprovementsLima = 6,\n Fate2 = 7,\n Fate3 = 8,\n}\n\n/**\n * @category contract\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}\n */\nexport enum AbiVersion {\n NoAbi = 0,\n Sophia = 1,\n Fate = 3,\n}\n\n/**\n * Enum with tag types\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}\n */\n// TODO: implement serialisation for commented-out tags\nexport enum Tag {\n SignedTx = 11,\n SpendTx = 12,\n OracleRegisterTx = 22,\n OracleQueryTx = 23,\n /**\n * @deprecated use `OracleRespondTx` instead\n */\n OracleResponseTx = 24,\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n OracleRespondTx = 24,\n OracleExtendTx = 25,\n NameClaimTx = 32,\n NamePreclaimTx = 33,\n NameUpdateTx = 34,\n NameRevokeTx = 35,\n NameTransferTx = 36,\n ContractCreateTx = 42,\n ContractCallTx = 43,\n ChannelCreateTx = 50,\n ChannelDepositTx = 51,\n ChannelWithdrawTx = 52,\n ChannelForceProgressTx = 521,\n ChannelCloseMutualTx = 53,\n ChannelCloseSoloTx = 54,\n ChannelSlashTx = 55,\n ChannelSettleTx = 56,\n ChannelOffChainTx = 57,\n ChannelSnapshotSoloTx = 59,\n GaAttachTx = 80,\n GaMetaTx = 81,\n PayingForTx = 82,\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,SAAS,QAAQ,sBAAsB;;AAEhD;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7BC,GAAG,EAAE,2CAA2C;EAChDC,MAAM,EAAE;AACV,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,KAAK;AACrC;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAG,GAAG,CAAC,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAG,IAAI;AACvC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,IAAI;AAC1C;AACA;AACA;AACA;A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
1
+ {"version":3,"file":"constants.js","names":["BigNumber","mapObject","DRY_RUN_ACCOUNT","pub","amount","MAX_AUTH_FUN_GAS","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_RANGES","key","value","times","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other.js';\n\n/**\n * @category transaction builder\n */\nexport const DRY_RUN_ACCOUNT = {\n pub: 'ak_11111111111111111111111111111111273Yts',\n amount: 100000000000000000000000000000000000n,\n} as const;\n\n/**\n * The maximum gas of a generalized account authentication function as it was at the moment of the\n * SDK release. It is a node policy setting rather than a consensus parameter.\n * @category account generalized\n * @deprecated the transaction builder ensures that gas doesn't exceed the maximum by itself, and a\n * node may accept another maximum than this constant. Use\n * `(await getCachedProtocolParameters(node)).maxAuthFunGas` for the value the connected node\n * reports, or `defaultProtocolParameters.maxAuthFunGas` for this one.\n */\nexport const MAX_AUTH_FUN_GAS = 50000;\n/**\n * @category utils\n */\nexport type Int = number | string | BigNumber;\n/**\n * @category AENS\n */\nexport type AensName = `${string}.chain`;\n/**\n * The consensus minimum gas price as it was at the moment of the SDK release.\n * @category transaction builder\n * @deprecated a node may run another minimum gas price, and this constant is wrong on it. Use\n * `getFloorGasPrice(await getCachedProtocolParameters(node))` to price a transaction for the\n * connected node — the consensus minimum it reports is below what its miner accepts on a public\n * network. `defaultProtocolParameters.minGasPrice` is this constant.\n */\nexport const MIN_GAS_PRICE = 1e9; // TODO: don't use number for ae\n/**\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67}\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_FEE_MULTIPLIER = 1e14;\n/**\n * The next bid should be at least 5% bigger than the previous one\n * @category AENS\n * @deprecated use {@link computeBidFee} instead\n */\nexport const NAME_FEE_BID_INCREMENT = 0.05;\n/**\n * Approximately 1 day\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272}\n * @deprecated use {@link computeAuctionEndBlock} instead\n */\nexport const NAME_BID_TIMEOUT_BLOCKS = 480;\n/**\n * This is the max length for a domain that requires a base fee to be paid\n * @category AENS\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_MAX_LENGTH_FEE = 31;\n/**\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290}\n * @see {@link https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times}\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_BID_RANGES = mapObject(\n {\n 31: 3,\n 30: 5,\n 29: 8,\n 28: 13,\n 27: 21,\n 26: 34,\n 25: 55,\n 24: 89,\n 23: 144,\n 22: 233,\n 21: 377,\n 20: 610,\n 19: 987,\n 18: 1597,\n 17: 2584,\n 16: 4181,\n 15: 6765,\n 14: 10946,\n 13: 17711,\n 12: 28657,\n 11: 46368,\n 10: 75025,\n 9: 121393,\n 8: 196418,\n 7: 317811,\n 6: 514229,\n 5: 832040,\n 4: 1346269,\n 3: 2178309,\n 2: 3524578,\n 1: 5702887,\n },\n ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)],\n);\n\n/**\n * @category chain\n */\nexport enum ConsensusProtocolVersion {\n Ceres = 6,\n Arcus = 7,\n}\n\n/**\n * @category contract\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}\n */\nexport enum VmVersion {\n NoVm = 0,\n Sophia = 1,\n SophiaImprovementsMinerva = 3,\n SophiaImprovementsFortuna = 4,\n Fate = 5,\n SophiaImprovementsLima = 6,\n Fate2 = 7,\n Fate3 = 8,\n}\n\n/**\n * @category contract\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}\n */\nexport enum AbiVersion {\n NoAbi = 0,\n Sophia = 1,\n Fate = 3,\n}\n\n/**\n * Enum with tag types\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}\n */\n// TODO: implement serialisation for commented-out tags\nexport enum Tag {\n SignedTx = 11,\n SpendTx = 12,\n OracleRegisterTx = 22,\n OracleQueryTx = 23,\n /**\n * @deprecated use `OracleRespondTx` instead\n */\n OracleResponseTx = 24,\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n OracleRespondTx = 24,\n OracleExtendTx = 25,\n NameClaimTx = 32,\n NamePreclaimTx = 33,\n NameUpdateTx = 34,\n NameRevokeTx = 35,\n NameTransferTx = 36,\n ContractCreateTx = 42,\n ContractCallTx = 43,\n ChannelCreateTx = 50,\n ChannelDepositTx = 51,\n ChannelWithdrawTx = 52,\n ChannelForceProgressTx = 521,\n ChannelCloseMutualTx = 53,\n ChannelCloseSoloTx = 54,\n ChannelSlashTx = 55,\n ChannelSettleTx = 56,\n ChannelOffChainTx = 57,\n ChannelSnapshotSoloTx = 59,\n GaAttachTx = 80,\n GaMetaTx = 81,\n PayingForTx = 82,\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,SAAS,QAAQ,sBAAsB;;AAEhD;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7BC,GAAG,EAAE,2C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AAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAA,OAAHA,GAAG;AAAA","ignoreList":[]}
@@ -1,10 +1,12 @@
1
1
  import { Buffer as _Buffer } from "buffer";
2
2
  import { Tag, ConsensusProtocolVersion } from '../constants.js';
3
- import { getProtocolDetails } from './ct-version.js';
3
+ import { getProtocolDetails, isProtocolIndependent } from './ct-version.js';
4
+ function getKind(tag) {
5
+ return Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call';
6
+ }
4
7
  export default {
5
8
  _getProtocolDetails(c, tag) {
6
- const kind = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call';
7
- return getProtocolDetails(c, kind).abiVersion;
9
+ return getProtocolDetails(c, getKind(tag)).abiVersion;
8
10
  },
9
11
  serialize(value, {
10
12
  tag
@@ -21,7 +23,7 @@ export default {
21
23
  options) {
22
24
  if (value != null) return value;
23
25
  if (options.consensusProtocolVersion != null) return undefined;
24
- if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
26
+ if (isProtocolIndependent(getKind(tag))) return undefined;
25
27
  if (options.onNode != null) {
26
28
  return this._getProtocolDetails((await options.onNode.getNodeInfo()).consensusProtocolVersion, tag);
27
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"abi-version.js","names":["Tag","ConsensusProtocolVersion","getProtocolDetails","_getProtocolDetails","c","tag","kind","ContractCallTx","GaMetaTx","abiVersion","serialize","value","consensusProtocolVersion","Ceres","result","_Buffer","from","prepare","options","undefined","Object","keys","length","onNode","getNodeInfo","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/abi-version.ts"],"sourcesContent":["import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants.js';\nimport { getProtocolDetails } from './ct-version.js';\nimport Node from '../../../Node.js';\n\nexport default {\n _getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion {\n const kind =\n Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call';\n return getProtocolDetails(c, kind).abiVersion;\n },\n\n serialize(\n value: AbiVersion | undefined,\n { tag }: { tag: Tag },\n {\n consensusProtocolVersion = ConsensusProtocolVersion.Ceres,\n }: { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n const result = value ?? this._getProtocolDetails(consensusProtocolVersion, tag);\n\n return Buffer.from([result]);\n },\n\n async prepare(\n value: AbiVersion | undefined,\n { tag }: { tag: Tag },\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<AbiVersion | undefined> {\n if (value != null) return value;\n if (options.consensusProtocolVersion != null) return undefined;\n if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;\n if (options.onNode != null) {\n return this._getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n tag,\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): AbiVersion {\n return buffer[0];\n },\n};\n"],"mappings":";AAAA,SAASA,GAAG,EAAEC,wBAAwB,QAAoB,iBAAiB;AAC3E,SAASC,kBAAkB,QAAQ,iBAAiB;AAGpD,eAAe;EACbC,mBAAmBA,CAACC,CAA2B,EAAEC,GAAQ,EAAc;IACrE,MAAMC,IAAI,GACRN,GAAG,CAACO,cAAc,KAAKF,GAAG,IAAIL,GAAG,CAACQ,QAAQ,KAAKH,GAAG,GAAG,eAAe,GAAG,aAAa;IACtF,OAAOH,kBAAkB,CAACE,CAAC,EAAEE,IAAI,CAAC,CAACG,UAAU;EAC/C,CAAC;EAEDC,SAASA,CACPC,KAA6B,EAC7B;IAAEN;EAAkB,CAAC,EACrB;IACEO,wBAAwB,GAAGX,wBAAwB,CAACY;EACG,CAAC,EAClD;IACR,MAAMC,MAAM,GAAGH,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,IAAI,CAACR,mBAAmB,CAACS,wBAAwB,EAAEP,GAAG,CAAC;IAE/E,OAAOU,OAAA,CAAOC,IAAI,CAAC,CAACF,MAAM,CAAC,CAAC;EAC9B,CAAC;EAED,MAAMG,OAAOA,CACXN,KAA6B,EAC7B;IAAEN;EAAkB,CAAC;EACrB;EACAa,OAA+E,EAC9C;IACjC,IAAIP,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;IAC/B,IAAIO,OAAO,CAACN,wBAAwB,IAAI,IAAI,EAAE,OAAOO,SAAS;IAC9D,IAAIC,MAAM,CAACC,IAAI,CAACpB,wBAAwB,CAAC,CAACqB,MAAM,KAAK,CAAC,EAAE,OAAOH,SAAS;IACxE,IAAID,OAAO,CAACK,MAAM,IAAI,IAAI,EAAE;MAC1B,OAAO,IAAI,CAACpB,mBAAmB,CAC7B,CAAC,MAAMe,OAAO,CAACK,MAAM,CAACC,WAAW,CAAC,CAAC,EAAEZ,wBAAwB,EAC7DP,GACF,CAAC;IACH;IACA,OAAOc,SAAS;EAClB,CAAC;EAEDM,WAAWA,CAACC,MAAc,EAAc;IACtC,OAAOA,MAAM,CAAC,CAAC,CAAC;EAClB;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"abi-version.js","names":["Tag","ConsensusProtocolVersion","getProtocolDetails","isProtocolIndependent","getKind","tag","ContractCallTx","GaMetaTx","_getProtocolDetails","c","abiVersion","serialize","value","consensusProtocolVersion","Ceres","result","_Buffer","from","prepare","options","undefined","onNode","getNodeInfo","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/abi-version.ts"],"sourcesContent":["import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants.js';\nimport { getProtocolDetails, isProtocolIndependent } from './ct-version.js';\nimport Node from '../../../Node.js';\n\nfunction getKind(tag: Tag): 'contract-call' | 'oracle-call' {\n return Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call';\n}\n\nexport default {\n _getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion {\n return getProtocolDetails(c, getKind(tag)).abiVersion;\n },\n\n serialize(\n value: AbiVersion | undefined,\n { tag }: { tag: Tag },\n {\n consensusProtocolVersion = ConsensusProtocolVersion.Ceres,\n }: { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n const result = value ?? this._getProtocolDetails(consensusProtocolVersion, tag);\n\n return Buffer.from([result]);\n },\n\n async prepare(\n value: AbiVersion | undefined,\n { tag }: { tag: Tag },\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<AbiVersion | undefined> {\n if (value != null) return value;\n if (options.consensusProtocolVersion != null) return undefined;\n if (isProtocolIndependent(getKind(tag))) return undefined;\n if (options.onNode != null) {\n return this._getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n tag,\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): AbiVersion {\n return buffer[0];\n },\n};\n"],"mappings":";AAAA,SAASA,GAAG,EAAEC,wBAAwB,QAAoB,iBAAiB;AAC3E,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,iBAAiB;AAG3E,SAASC,OAAOA,CAACC,GAAQ,EAAmC;EAC1D,OAAOL,GAAG,CAACM,cAAc,KAAKD,GAAG,IAAIL,GAAG,CAACO,QAAQ,KAAKF,GAAG,GAAG,eAAe,GAAG,aAAa;AAC7F;AAEA,eAAe;EACbG,mBAAmBA,CAACC,CAA2B,EAAEJ,GAAQ,EAAc;IACrE,OAAOH,kBAAkB,CAACO,CAAC,EAAEL,OAAO,CAACC,GAAG,CAAC,CAAC,CAACK,UAAU;EACvD,CAAC;EAEDC,SAASA,CACPC,KAA6B,EAC7B;IAAEP;EAAkB,CAAC,EACrB;IACEQ,wBAAwB,GAAGZ,wBAAwB,CAACa;EACG,CAAC,EAClD;IACR,MAAMC,MAAM,GAAGH,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,IAAI,CAACJ,mBAAmB,CAACK,wBAAwB,EAAER,GAAG,CAAC;IAE/E,OAAOW,OAAA,CAAOC,IAAI,CAAC,CAACF,MAAM,CAAC,CAAC;EAC9B,CAAC;EAED,MAAMG,OAAOA,CACXN,KAA6B,EAC7B;IAAEP;EAAkB,CAAC;EACrB;EACAc,OAA+E,EAC9C;IACjC,IAAIP,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;IAC/B,IAAIO,OAAO,CAACN,wBAAwB,IAAI,IAAI,EAAE,OAAOO,SAAS;IAC9D,IAAIjB,qBAAqB,CAACC,OAAO,CAACC,GAAG,CAAC,CAAC,EAAE,OAAOe,SAAS;IACzD,IAAID,OAAO,CAACE,MAAM,IAAI,IAAI,EAAE;MAC1B,OAAO,IAAI,CAACb,mBAAmB,CAC7B,CAAC,MAAMW,OAAO,CAACE,MAAM,CAACC,WAAW,CAAC,CAAC,EAAET,wBAAwB,EAC7DR,GACF,CAAC;IACH;IACA,OAAOe,SAAS;EAClB,CAAC;EAEDG,WAAWA,CAACC,MAAc,EAAc;IACtC,OAAOA,MAAM,CAAC,CAAC,CAAC;EAClB;AACF,CAAC","ignoreList":[]}
@@ -35,6 +35,11 @@ export interface CtVersion {
35
35
  abiVersion: AbiVersion;
36
36
  }
37
37
  export declare function getProtocolDetails(protocolVersion: ConsensusProtocolVersion, type: 'contract-create' | 'contract-call' | 'oracle-call'): CtVersion;
38
+ /**
39
+ * Whether all known consensus protocols pick the same versions for `type`, so asking node for its
40
+ * protocol can't change them.
41
+ */
42
+ export declare function isProtocolIndependent(type: 'contract-create' | 'contract-call' | 'oracle-call'): boolean;
38
43
  declare const _default: {
39
44
  serialize(value: CtVersion | undefined, params: {}, { consensusProtocolVersion, }: {
40
45
  consensusProtocolVersion?: ConsensusProtocolVersion;
@@ -42,6 +42,18 @@ export function getProtocolDetails(protocolVersion, type) {
42
42
  abiVersion: protocol.abiVersion[0]
43
43
  };
44
44
  }
45
+
46
+ /**
47
+ * Whether all known consensus protocols pick the same versions for `type`, so asking node for its
48
+ * protocol can't change them.
49
+ */
50
+ export function isProtocolIndependent(type) {
51
+ const [first, ...others] = Object.keys(ProtocolToVmAbi).map(protocol => getProtocolDetails(+protocol, type));
52
+ return others.every(({
53
+ vmVersion,
54
+ abiVersion
55
+ }) => vmVersion === first.vmVersion && abiVersion === first.abiVersion);
56
+ }
45
57
  export default {
46
58
  serialize(value, params, {
47
59
  consensusProtocolVersion = ConsensusProtocolVersion.Ceres
@@ -54,7 +66,7 @@ export default {
54
66
  options) {
55
67
  if (value != null) return value;
56
68
  if (options.consensusProtocolVersion != null) return undefined;
57
- if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
69
+ if (isProtocolIndependent('contract-create')) return undefined;
58
70
  if (options.onNode != null) {
59
71
  return getProtocolDetails((await options.onNode.getNodeInfo()).consensusProtocolVersion, 'contract-create');
60
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ct-version.js","names":["ConsensusProtocolVersion","VmVersion","AbiVersion","ProtocolToVmAbi","Ceres","vmVersion","Fate3","abiVersion","Fate","NoAbi","Arcus","getProtocolDetails","protocolVersion","type","_protocol$vmVersion$","protocol","Fate2","serialize","value","params","consensusProtocolVersion","_Buffer","from","prepare","options","undefined","Object","keys","length","onNode","getNodeInfo","deserialize","buffer","vm","abi"],"sources":["../../../../src/tx/builder/field-types/ct-version.ts"],"sourcesContent":["import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants.js';\nimport Node from '../../../Node.js';\n\n/*\n * First abi/vm by default\n * @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}\n */\nexport const ProtocolToVmAbi = {\n [ConsensusProtocolVersion.Ceres]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate3],\n abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n [ConsensusProtocolVersion.Arcus]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate3],\n abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n} as const;\n\nexport interface CtVersion {\n vmVersion: VmVersion;\n abiVersion: AbiVersion;\n}\n\nexport function getProtocolDetails(\n protocolVersion: ConsensusProtocolVersion,\n type: 'contract-create' | 'contract-call' | 'oracle-call',\n): CtVersion {\n const protocol = ProtocolToVmAbi[protocolVersion][type];\n return {\n vmVersion: protocol.vmVersion[0] ?? VmVersion.Fate2,\n abiVersion: protocol.abiVersion[0],\n };\n}\n\nexport default {\n serialize(\n value: CtVersion | undefined,\n params: {},\n {\n consensusProtocolVersion = ConsensusProtocolVersion.Ceres,\n }: { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');\n\n return Buffer.from([value.vmVersion, 0, value.abiVersion]);\n },\n\n async prepare(\n value: CtVersion | undefined,\n params: {},\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<CtVersion | undefined> {\n if (value != null) return value;\n if (options.consensusProtocolVersion != null) return undefined;\n if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;\n if (options.onNode != null) {\n return getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n 'contract-create',\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): CtVersion {\n const [vm, , abi] = buffer;\n return { vmVersion: +vm, abiVersion: +abi };\n },\n};\n"],"mappings":";AAAA,SAASA,wBAAwB,EAAEC,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AAGjF;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7B,CAACH,wBAAwB,CAACI,KAAK,GAAG;IAChC,iBAAiB,EAAE;MACjBC,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAC5BC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,aAAa,EAAE;MACbH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACO,KAAK,EAAEP,UAAU,CAACM,IAAI;IAChD;EACF,CAAC;EACD,CAACR,wBAAwB,CAACU,KAAK,GAAG;IAChC,iBAAiB,EAAE;MACjBL,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAC5BC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,aAAa,EAAE;MACbH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACO,KAAK,EAAEP,UAAU,CAACM,IAAI;IAChD;EACF;AACF,CAAU;AAOV,OAAO,SAASG,kBAAkBA,CAChCC,eAAyC,EACzCC,IAAyD,EAC9C;EAAA,IAAAC,oBAAA;EACX,MAAMC,QAAQ,GAAGZ,eAAe,CAACS,eAAe,CAAC,CAAC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EAC7C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ct-version.js","names":["ConsensusProtocolVersion","VmVersion","AbiVersion","ProtocolToVmAbi","Ceres","vmVersion","Fate3","abiVersion","Fate","NoAbi","Arcus","getProtocolDetails","protocolVersion","type","_protocol$vmVersion$","protocol","Fate2","isProtocolIndependent","first","others","Object","keys","map","every","serialize","value","params","consensusProtocolVersion","_Buffer","from","prepare","options","undefined","onNode","getNodeInfo","deserialize","buffer","vm","abi"],"sources":["../../../../src/tx/builder/field-types/ct-version.ts"],"sourcesContent":["import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants.js';\nimport Node from '../../../Node.js';\n\n/*\n * First abi/vm by default\n * @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}\n */\nexport const ProtocolToVmAbi = {\n [ConsensusProtocolVersion.Ceres]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate3],\n abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n [ConsensusProtocolVersion.Arcus]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate3],\n abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n} as const;\n\nexport interface CtVersion {\n vmVersion: VmVersion;\n abiVersion: AbiVersion;\n}\n\nexport function getProtocolDetails(\n protocolVersion: ConsensusProtocolVersion,\n type: 'contract-create' | 'contract-call' | 'oracle-call',\n): CtVersion {\n const protocol = ProtocolToVmAbi[protocolVersion][type];\n return {\n vmVersion: protocol.vmVersion[0] ?? VmVersion.Fate2,\n abiVersion: protocol.abiVersion[0],\n };\n}\n\n/**\n * Whether all known consensus protocols pick the same versions for `type`, so asking node for its\n * protocol can't change them.\n */\nexport function isProtocolIndependent(\n type: 'contract-create' | 'contract-call' | 'oracle-call',\n): boolean {\n const [first, ...others] = Object.keys(ProtocolToVmAbi).map((protocol) =>\n getProtocolDetails(+protocol as ConsensusProtocolVersion, type),\n );\n return others.every(\n ({ vmVersion, abiVersion }) => vmVersion === first.vmVersion && abiVersion === first.abiVersion,\n );\n}\n\nexport default {\n serialize(\n value: CtVersion | undefined,\n params: {},\n {\n consensusProtocolVersion = ConsensusProtocolVersion.Ceres,\n }: { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');\n\n return Buffer.from([value.vmVersion, 0, value.abiVersion]);\n },\n\n async prepare(\n value: CtVersion | undefined,\n params: {},\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<CtVersion | undefined> {\n if (value != null) return value;\n if (options.consensusProtocolVersion != null) return undefined;\n if (isProtocolIndependent('contract-create')) return undefined;\n if (options.onNode != null) {\n return getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n 'contract-create',\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): CtVersion {\n const [vm, , abi] = buffer;\n return { vmVersion: +vm, abiVersion: +abi };\n },\n};\n"],"mappings":";AAAA,SAASA,wBAAwB,EAAEC,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AAGjF;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7B,CAACH,wBAAwB,CAACI,KAAK,GAAG;IAChC,iBAAiB,EAAE;MACjBC,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAC5BC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;M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B,SAAS;IAAEE;EAAW,CAAC,KAAKF,SAAS,KAAKa,KAAK,CAACb,SAAS,IAAIE,UAAU,KAAKW,KAAK,CAACX,UACvF,CAAC;AACH;AAEA,eAAe;EACbiB,SAASA,CACPC,KAA4B,EAC5BC,MAAU,EACV;IACEC,wBAAwB,GAAG3B,wBAAwB,CAACI;EACG,CAAC,EAClD;IACRqB,KAAK,aAALA,KAAK,cAALA,KAAK,GAALA,KAAK,GAAKd,kBAAkB,CAACgB,wBAAwB,EAAE,iBAAiB,CAAC;IAEzE,OAAOC,OAAA,CAAOC,IAAI,CAAC,CAACJ,KAAK,CAACpB,SAAS,EAAE,CAAC,EAAEoB,KAAK,CAAClB,UAAU,CAAC,CAAC;EAC5D,CAAC;EAED,MAAMuB,OAAOA,CACXL,KAA4B,EAC5BC,MAAU;EACV;EACAK,OAA+E,EAC/C;IAChC,IAAIN,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;IAC/B,IAAIM,OAAO,CAACJ,wBAAwB,IAAI,IAAI,EAAE,OAAOK,SAAS;IAC9D,IAAIf,qBAAqB,CAAC,iBAAiB,CAAC,EAAE,OAAOe,SAAS;IAC9D,IAAID,OAAO,CAACE,MAAM,IAAI,IAAI,EAAE;MAC1B,OAAOtB,kBAAkB,CACvB,CAAC,MAAMoB,OAAO,CAACE,MAAM,CAACC,WAAW,CAAC,CAAC,EAAEP,wBAAwB,EAC7D,iBACF,CAAC;IACH;IACA,OAAOK,SAAS;EAClB,CAAC;EAEDG,WAAWA,CAACC,MAAc,EAAa;IACrC,MAAM,CAACC,EAAE,GAAIC,GAAG,CAAC,GAAGF,MAAM;IAC1B,OAAO;MAAE/B,SAAS,EAAE,CAACgC,EAAE;MAAE9B,UAAU,EAAE,CAAC+B;IAAI,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { ArgumentError, IllegalArgumentError, InternalError } from '../../../utils/errors.js';
3
3
  import { Tag } from '../constants.js';
4
- import { defaultProtocolParameters, maxOf } from '../protocol-parameters.js';
4
+ import { defaultProtocolParameters, getFloorGasPrice, maxOf } from '../protocol-parameters.js';
5
5
  import uInt from './u-int.js';
6
6
  import coinAmount from './coin-amount.js';
7
7
  import { getCachedIncreasedGasPrice } from './gas-price.js';
@@ -109,12 +109,12 @@ export function buildGas(builtTx, unpackTx, buildTx, protocolParameters) {
109
109
  * @param rebuildTx - Callback to get built transaction with specific fee
110
110
  */
111
111
  function calculateMinFee(rebuildTx, unpackTx, buildTx, protocolParameters) {
112
- const minGasPrice = new BigNumber(protocolParameters.minGasPrice.toString());
112
+ const floorGasPrice = new BigNumber(getFloorGasPrice(protocolParameters).toString());
113
113
  let fee = new BigNumber(0);
114
114
  let previousFee;
115
115
  do {
116
116
  previousFee = fee;
117
- fee = minGasPrice.times(buildGas(rebuildTx(fee), unpackTx, buildTx, protocolParameters));
117
+ fee = floorGasPrice.times(buildGas(rebuildTx(fee), unpackTx, buildTx, protocolParameters));
118
118
  } while (!fee.eq(previousFee));
119
119
  return fee;
120
120
  }
@@ -152,7 +152,7 @@ export default {
152
152
  const minFee = calculateMinFee(fee => rebuildTx({
153
153
  _computingMinFee: fee
154
154
  }), unpackTx, buildTx, protocolParameters);
155
- const value = _value?.startsWith(gasPricePrefix) === true ? minFee.dividedBy(protocolParameters.minGasPrice.toString()).times(_value.replace(gasPricePrefix, '')) : new BigNumber(_value !== null && _value !== void 0 ? _value : minFee);
155
+ const value = _value?.startsWith(gasPricePrefix) === true ? minFee.dividedBy(getFloorGasPrice(protocolParameters).toString()).times(_value.replace(gasPricePrefix, '')) : new BigNumber(_value !== null && _value !== void 0 ? _value : minFee);
156
156
  if (minFee.gt(value)) {
157
157
  if (_canIncreaseFee === true) return minFee.toFixed();
158
158
  throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger than ${minFee}`);
@@ -1 +1 @@
1
- {"version":3,"file":"fee.js","names":["BigNumber","ArgumentError","IllegalArgumentError","InternalError","Tag","defaultProtocolParameters","maxOf","uInt","coinAmount","getCachedIncreasedGasPrice","isKeyOfObject","serializeAsIsParam","decode","getTxBaseGas","txObject","protocolParameters","tag","byAbiVersion","contractTxBaseGas","_txObject$ctVersion$a","abiVersion","ctVersion","gas","Object","prototype","hasOwnProperty","call","undefined","knownAbiVersions","values","length","txBaseGas","getTxOtherGas","txType","txSize","relativeTtl","innerTxSize","gasPerByte","isMeta","GaMetaTx","PayingForTx","sizeGas","stateGas","stateGasPerBlock","Math","ceil","part","whole","getOracleRelativeTtl","params","ttlKeys","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleRespondTx","buildGas","builtTx","unpackTx","buildTx","innerTx","tx","encodedTx","calculateMinFee","rebuildTx","minGasPrice","toString","fee","previousFee","times","eq","gasPricePrefix","prepare","value","onNode","gasPrice","serializeAettos","_value","_canIncreaseFee","_computingMinFee","toFixed","minFee","startsWith","dividedBy","replace","gt","serialize","options"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { ArgumentError, IllegalArgumentError, InternalError } from '../../../utils/errors.js';\nimport { Int, Tag } from '../constants.js';\nimport {\n defaultProtocolParameters,\n maxOf,\n ProtocolParameters,\n ProtocolParametersOption,\n} from '../protocol-parameters.js';\nimport uInt from './u-int.js';\nimport coinAmount from './coin-amount.js';\nimport { getCachedIncreasedGasPrice } from './gas-price.js';\nimport { isKeyOfObject } from '../../../utils/other.js';\nimport { serializeAsIsParam, SerializeAsIsParams } from './interface.js';\nimport { decode, Encoded } from '../../../utils/encoder.js';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js';\nimport Node from '../../../Node.js';\n\n/**\n * Get the base gas\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txObject - The unpacked transaction\n * @param protocolParameters - The protocol parameters\n * @returns The base gas\n */\nfunction getTxBaseGas(txObject: any, protocolParameters: ProtocolParameters): number {\n const { tag }: { tag: Tag } = txObject;\n const byAbiVersion = protocolParameters.contractTxBaseGas[tag];\n if (byAbiVersion != null) {\n const abiVersion = txObject.ctVersion?.abiVersion ?? txObject.abiVersion;\n // read only what the checks in `protocol-parameters.ts` iterate, so that the two can't\n // disagree about what the parameters hold — anything inherited is not a base gas\n const gas = Object.prototype.hasOwnProperty.call(byAbiVersion, abiVersion)\n ? byAbiVersion[abiVersion as keyof typeof byAbiVersion]\n : undefined;\n if (gas != null) return gas;\n // node charges the maximum base gas for an abi version it doesn't know\n const knownAbiVersions = Object.values(byAbiVersion);\n // the maximum of nothing is `-Infinity`, fall through to `txBaseGas` instead\n if (knownAbiVersions.length !== 0) return maxOf(knownAbiVersions);\n }\n const gas = protocolParameters.txBaseGas[tag];\n if (gas == null) throw new InternalError(`Base gas of ${Tag[tag]} is not known`);\n return gas;\n}\n\n/**\n * Calculate gas for other types of transactions\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @param txSize - The transaction size\n * @param parameters - The transaction parameters\n * @param parameters.relativeTtl - The relative ttl\n * @param parameters.innerTxSize - The size of the inner transaction\n * @param protocolParameters - The protocol parameters\n * @returns The other gas\n */\nfunction getTxOtherGas(\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n protocolParameters: ProtocolParameters,\n): number {\n const { gasPerByte } = protocolParameters;\n // the inner transaction of a meta transaction pays for its own bytes in its own fee. The\n // deduction is separate from the state gas below: node reporting a state gas fraction for\n // `GaMetaTx`/`PayingForTx` must not cancel it — that would charge the inner transaction twice\n const isMeta = txType === Tag.GaMetaTx || txType === Tag.PayingForTx;\n const sizeGas = (isMeta ? txSize - innerTxSize : txSize) * gasPerByte;\n // oracle transactions pay a state rent for the time their entry occupies the state tree\n const stateGas = protocolParameters.stateGasPerBlock[txType];\n if (stateGas == null) return sizeGas;\n return sizeGas + Math.ceil((stateGas.part * relativeTtl) / stateGas.whole);\n}\n\nfunction getOracleRelativeTtl(params: any): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleRespondTx]: 'responseTtlValue',\n } as const;\n\n const { tag } = params;\n if (!isKeyOfObject(tag, ttlKeys)) return 1;\n return params[ttlKeys[tag]];\n}\n\n/**\n * Calculate gas based on tx type and params\n */\nexport function buildGas(\n builtTx: Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n protocolParameters: ProtocolParameters,\n): number {\n const { length } = decode(builtTx);\n const txObject = unpackTx(builtTx);\n\n let innerTxSize = 0;\n if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {\n // this rebuild only measures the size of an already signed inner transaction, its values are\n // serialized as they are — see `serializeAsIsParam`\n const innerTx = { ...txObject.tx.encodedTx, [serializeAsIsParam]: true };\n innerTxSize = decode(buildTx(innerTx as Parameters<typeof buildTx>[0])).length;\n }\n\n return (\n getTxBaseGas(txObject, protocolParameters) +\n getTxOtherGas(\n txObject.tag,\n length,\n { relativeTtl: getOracleRelativeTtl(txObject), innerTxSize },\n protocolParameters,\n )\n );\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nfunction calculateMinFee(\n rebuildTx: (value: BigNumber) => Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n protocolParameters: ProtocolParameters,\n): BigNumber {\n const minGasPrice = new BigNumber(protocolParameters.minGasPrice.toString());\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = minGasPrice.times(buildGas(rebuildTx(fee), unpackTx, buildTx, protocolParameters));\n } while (!fee.eq(previousFee));\n return fee;\n}\n\n// TODO: Get rid of this workaround. Transaction builder can't accept/return gas price instead of\n// fee because it may get a decimal gas price. So, it should accept the optional `gasPrice` even\n// if it is not a contract-related transaction. And use this `gasPrice` to calculate `fee`.\nconst gasPricePrefix = '_gas-price:';\n\nexport interface SerializeAettosParams extends SerializeAsIsParams {\n rebuildTx: (params: any) => Encoded.Transaction;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n _computingMinFee?: BigNumber;\n}\n\nexport default {\n ...coinAmount,\n\n async prepare(\n value: Int | undefined,\n params: {},\n { onNode, protocolParameters }: { onNode?: Node } & ProtocolParametersOption,\n ): Promise<Int | undefined> {\n if (value != null) return value;\n if (onNode == null) {\n throw new ArgumentError('onNode', 'provided (or provide `fee` instead)', onNode);\n }\n const gasPrice = await getCachedIncreasedGasPrice(onNode, protocolParameters);\n if (gasPrice === 0n) return undefined;\n return gasPricePrefix + gasPrice;\n },\n\n serializeAettos(\n _value: string | undefined,\n params: SerializeAettosParams,\n {\n _canIncreaseFee,\n protocolParameters = defaultProtocolParameters,\n }: { _canIncreaseFee?: boolean } & ProtocolParametersOption,\n ): string {\n const { rebuildTx, unpackTx, buildTx, _computingMinFee } = params;\n if (_computingMinFee != null) return _computingMinFee.toFixed();\n if (params[serializeAsIsParam] === true && _value != null)\n return new BigNumber(_value).toFixed();\n const minFee = calculateMinFee(\n (fee) => rebuildTx({ _computingMinFee: fee }),\n unpackTx,\n buildTx,\n protocolParameters,\n );\n const value =\n _value?.startsWith(gasPricePrefix) === true\n ? minFee\n .dividedBy(protocolParameters.minGasPrice.toString())\n .times(_value.replace(gasPricePrefix, ''))\n : new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n if (_canIncreaseFee === true) return minFee.toFixed();\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger than ${minFee}`);\n }\n return value.toFixed();\n },\n\n serialize(\n value: Parameters<typeof coinAmount.serialize>[0],\n params: Parameters<typeof coinAmount.serialize>[1] & SerializeAettosParams,\n options: { _canIncreaseFee?: boolean } & ProtocolParametersOption &\n Parameters<typeof coinAmount.serialize>[2],\n ): Buffer {\n if (typeof value === 'string' && value.startsWith(gasPricePrefix)) {\n return uInt.serialize(this.serializeAettos(value, params, options));\n }\n return coinAmount.serialize.call(this, value, params, options);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,aAAa,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ,0BAA0B;AAC7F,SAAcC,GAAG,QAAQ,iBAAiB;AAC1C,SACEC,yBAAyB,EACzBC,KAAK,QAGA,2BAA2B;AAClC,OAAOC,IAAI,MAAM,YAAY;AAC7B,OAAOC,UAAU,MAAM,kBAAkB;AACzC,SAASC,0BAA0B,QAAQ,gBAAgB;AAC3D,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,kBAAkB,QAA6B,gBAAgB;AACxE,SAASC,MAAM,QAAiB,2BAA2B;AAI3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAACC,QAAa,EAAEC,kBAAsC,EAAU;EACnF,MAAM;IAAEC;EAAkB,CAAC,GAAGF,QAAQ;EACtC,MAAMG,YAAY,GAAGF,kBAAkB,CAACG,iBAAiB,CAACF,GAAG,CAAC;EAC9D,IAAIC,YAAY,IAAI,IAAI,EAAE;IAAA,IAAAE,qBAAA;IACxB,MAAMC,UAAU,IAAAD,qBAAA,GAAGL,QAAQ,CAACO,SAAS,EAAED,UAAU,cAAAD,qBAAA,cAAAA,qBAAA,GAAIL,QAAQ,CAACM,UAAU;IACxE;IACA;IACA,MAAME,GAAG,GAAGC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACT,YAAY,EAAEG,UAAU,CAAC,GACtEH,YAAY,CAACG,UAAU,CAA8B,GACrDO,SAAS;IACb,IAAIL,GAAG,IAAI,IAAI,EAAE,OAAOA,GAAG;IAC3B;IACA,MAAMM,gBAAgB,GAAGL,MAAM,CAACM,MAAM,CAACZ,YAAY,CAAC;IACpD;IACA,IAAIW,gBAAgB,CAACE,MAAM,KAAK,CAAC,EAAE,OAAOxB,KAAK,CAACsB,gBAAgB,CAAC;EACn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AAKH,SAAS,CAAC;MAAEe,gBAAgB,EAAEZ;IAAI,CAAC,CAAC,EAC7CT,QAAQ,EACRC,OAAO,EACP3C,kBACF,CAAC;IACD,MAAMyD,KAAK,GACTI,MAAM,EAAEK,UAAU,CAACX,cAAc,CAAC,KAAK,IAAI,GACvCU,MAAM,CACHE,SAAS,CAACnE,kBAAkB,CAACiD,WAAW,CAACC,QAAQ,CAAC,CAAC,CAAC,CACpDG,KAAK,CAACQ,MAAM,CAACO,OAAO,CAACb,cAAc,EAAE,EAAE,CAAC,CAAC,GAC5C,IAAItE,SAAS,CAAC4E,MAAM,aAANA,MAAM,cAANA,MAAM,GAAII,MAAM,CAAC;IACrC,IAAIA,MAAM,CAACI,EAAE,CAACZ,KAAK,CAAC,EAAE;MACpB,IAAIK,eAAe,KAAK,IAAI,EAAE,OAAOG,MAAM,CAACD,OAAO,CAAC,CAAC;MACrD,MAAM,IAAI7E,oBAAoB,CAAC,OAAOsE,KAAK,CAACP,QAAQ,CAAC,CAAC,wBAAwBe,MAAM,EAAE,CAAC;IACzF;IACA,OAAOR,KAAK,CAACO,OAAO,CAAC,CAAC;EACxB,CAAC;EAEDM,SAASA,CACPb,KAAiD,EACjDvB,MAA0E,EAC1EqC,OAC4C,EACpC;IACR,IAAI,OAAOd,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACS,UAAU,CAACX,cAAc,CAAC,EAAE;MACjE,OAAO/D,IAAI,CAAC8E,SAAS,CAAC,IAAI,CAACV,eAAe,CAACH,KAAK,EAAEvB,MAAM,EAAEqC,OAAO,CAAC,CAAC;IACrE;IACA,OAAO9E,UAAU,CAAC6E,SAAS,CAAC3D,IAAI,CAAC,IAAI,EAAE8C,KAAK,EAAEvB,MAAM,EAAEqC,OAAO,CAAC;EAChE;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"fee.js","names":["BigNumber","ArgumentError","IllegalArgumentError","InternalError","Tag","defaultProtocolParameters","getFloorGasPrice","maxOf","uInt","coinAmount","getCachedIncreasedGasPrice","isKeyOfObject","serializeAsIsParam","decode","getTxBaseGas","txObject","protocolParameters","tag","byAbiVersion","contractTxBaseGas","_txObject$ctVersion$a","abiVersion","ctVersion","gas","Object","prototype","hasOwnProperty","call","undefined","knownAbiVersions","values","length","txBaseGas","getTxOtherGas","txType","txSize","relativeTtl","innerTxSize","gasPerByte","isMeta","GaMetaTx","PayingForTx","sizeGas","stateGas","stateGasPerBlock","Math","ceil","part","whole","getOracleRelativeTtl","params","ttlKeys","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleRespondTx","buildGas","builtTx","unpackTx","buildTx","innerTx","tx","encodedTx","calculateMinFee","rebuildTx","floorGasPrice","toString","fee","previousFee","times","eq","gasPricePrefix","prepare","value","onNode","gasPrice","serializeAettos","_value","_canIncreaseFee","_computingMinFee","toFixed","minFee","startsWith","dividedBy","replace","gt","serialize","options"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { ArgumentError, IllegalArgumentError, InternalError } from '../../../utils/errors.js';\nimport { Int, Tag } from '../constants.js';\nimport {\n defaultProtocolParameters,\n getFloorGasPrice,\n maxOf,\n ProtocolParameters,\n ProtocolParametersOption,\n} from '../protocol-parameters.js';\nimport uInt from './u-int.js';\nimport coinAmount from './coin-amount.js';\nimport { getCachedIncreasedGasPrice } from './gas-price.js';\nimport { isKeyOfObject } from '../../../utils/other.js';\nimport { serializeAsIsParam, SerializeAsIsParams } from './interface.js';\nimport { decode, Encoded } from '../../../utils/encoder.js';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js';\nimport Node from '../../../Node.js';\n\n/**\n * Get the base gas\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txObject - The unpacked transaction\n * @param protocolParameters - The protocol parameters\n * @returns The base gas\n */\nfunction getTxBaseGas(txObject: any, protocolParameters: ProtocolParameters): number {\n const { tag }: { tag: Tag } = txObject;\n const byAbiVersion = protocolParameters.contractTxBaseGas[tag];\n if (byAbiVersion != null) {\n const abiVersion = txObject.ctVersion?.abiVersion ?? txObject.abiVersion;\n // read only what the checks in `protocol-parameters.ts` iterate, so that the two can't\n // disagree about what the parameters hold — anything inherited is not a base gas\n const gas = Object.prototype.hasOwnProperty.call(byAbiVersion, abiVersion)\n ? byAbiVersion[abiVersion as keyof typeof byAbiVersion]\n : undefined;\n if (gas != null) return gas;\n // node charges the maximum base gas for an abi version it doesn't know\n const knownAbiVersions = Object.values(byAbiVersion);\n // the maximum of nothing is `-Infinity`, fall through to `txBaseGas` instead\n if (knownAbiVersions.length !== 0) return maxOf(knownAbiVersions);\n }\n const gas = protocolParameters.txBaseGas[tag];\n if (gas == null) throw new InternalError(`Base gas of ${Tag[tag]} is not known`);\n return gas;\n}\n\n/**\n * Calculate gas for other types of transactions\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @param txSize - The transaction size\n * @param parameters - The transaction parameters\n * @param parameters.relativeTtl - The relative ttl\n * @param parameters.innerTxSize - The size of the inner transaction\n * @param protocolParameters - The protocol parameters\n * @returns The other gas\n */\nfunction getTxOtherGas(\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n protocolParameters: ProtocolParameters,\n): number {\n const { gasPerByte } = protocolParameters;\n // the inner transaction of a meta transaction pays for its own bytes in its own fee. The\n // deduction is separate from the state gas below: node reporting a state gas fraction for\n // `GaMetaTx`/`PayingForTx` must not cancel it — that would charge the inner transaction twice\n const isMeta = txType === Tag.GaMetaTx || txType === Tag.PayingForTx;\n const sizeGas = (isMeta ? txSize - innerTxSize : txSize) * gasPerByte;\n // oracle transactions pay a state rent for the time their entry occupies the state tree\n const stateGas = protocolParameters.stateGasPerBlock[txType];\n if (stateGas == null) return sizeGas;\n return sizeGas + Math.ceil((stateGas.part * relativeTtl) / stateGas.whole);\n}\n\nfunction getOracleRelativeTtl(params: any): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleRespondTx]: 'responseTtlValue',\n } as const;\n\n const { tag } = params;\n if (!isKeyOfObject(tag, ttlKeys)) return 1;\n return params[ttlKeys[tag]];\n}\n\n/**\n * Calculate gas based on tx type and params\n */\nexport function buildGas(\n builtTx: Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n protocolParameters: ProtocolParameters,\n): number {\n const { length } = decode(builtTx);\n const txObject = unpackTx(builtTx);\n\n let innerTxSize = 0;\n if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {\n // this rebuild only measures the size of an already signed inner transaction, its values are\n // serialized as they are — see `serializeAsIsParam`\n const innerTx = { ...txObject.tx.encodedTx, [serializeAsIsParam]: true };\n innerTxSize = decode(buildTx(innerTx as Parameters<typeof buildTx>[0])).length;\n }\n\n return (\n getTxBaseGas(txObject, protocolParameters) +\n getTxOtherGas(\n txObject.tag,\n length,\n { relativeTtl: getOracleRelativeTtl(txObject), innerTxSize },\n protocolParameters,\n )\n );\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nfunction calculateMinFee(\n rebuildTx: (value: BigNumber) => Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n protocolParameters: ProtocolParameters,\n): BigNumber {\n const floorGasPrice = new BigNumber(getFloorGasPrice(protocolParameters).toString());\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = floorGasPrice.times(buildGas(rebuildTx(fee), unpackTx, buildTx, protocolParameters));\n } while (!fee.eq(previousFee));\n return fee;\n}\n\n// TODO: Get rid of this workaround. Transaction builder can't accept/return gas price instead of\n// fee because it may get a decimal gas price. So, it should accept the optional `gasPrice` even\n// if it is not a contract-related transaction. And use this `gasPrice` to calculate `fee`.\nconst gasPricePrefix = '_gas-price:';\n\nexport interface SerializeAettosParams extends SerializeAsIsParams {\n rebuildTx: (params: any) => Encoded.Transaction;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n _computingMinFee?: BigNumber;\n}\n\nexport default {\n ...coinAmount,\n\n async prepare(\n value: Int | undefined,\n params: {},\n { onNode, protocolParameters }: { onNode?: Node } & ProtocolParametersOption,\n ): Promise<Int | undefined> {\n if (value != null) return value;\n if (onNode == null) {\n throw new ArgumentError('onNode', 'provided (or provide `fee` instead)', onNode);\n }\n const gasPrice = await getCachedIncreasedGasPrice(onNode, protocolParameters);\n if (gasPrice === 0n) return undefined;\n return gasPricePrefix + gasPrice;\n },\n\n serializeAettos(\n _value: string | undefined,\n params: SerializeAettosParams,\n {\n _canIncreaseFee,\n protocolParameters = defaultProtocolParameters,\n }: { _canIncreaseFee?: boolean } & ProtocolParametersOption,\n ): string {\n const { rebuildTx, unpackTx, buildTx, _computingMinFee } = params;\n if (_computingMinFee != null) return _computingMinFee.toFixed();\n if (params[serializeAsIsParam] === true && _value != null)\n return new BigNumber(_value).toFixed();\n const minFee = calculateMinFee(\n (fee) => rebuildTx({ _computingMinFee: fee }),\n unpackTx,\n buildTx,\n protocolParameters,\n );\n const value =\n _value?.startsWith(gasPricePrefix) === true\n ? minFee\n .dividedBy(getFloorGasPrice(protocolParameters).toString())\n .times(_value.replace(gasPricePrefix, ''))\n : new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n if (_canIncreaseFee === true) return minFee.toFixed();\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger than ${minFee}`);\n }\n return value.toFixed();\n },\n\n serialize(\n value: Parameters<typeof coinAmount.serialize>[0],\n params: Parameters<typeof coinAmount.serialize>[1] & SerializeAettosParams,\n options: { _canIncreaseFee?: boolean } & ProtocolParametersOption &\n Parameters<typeof coinAmount.serialize>[2],\n ): Buffer {\n if (typeof value === 'string' && value.startsWith(gasPricePrefix)) {\n return uInt.serialize(this.serializeAettos(value, params, options));\n }\n return coinAmount.serialize.call(this, value, params, options);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,aAAa,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ,0BAA0B;AAC7F,SAAcC,GAAG,QAAQ,iBAAiB;AAC1C,SACEC,yBAAyB,EACzBC,gBAAgB,EAChBC,KAAK,QAGA,2BAA2B;AAClC,OAAOC,IAAI,MAAM,YAAY;AAC7B,OAAOC,UAAU,MAAM,kBAAkB;AACzC,SAASC,0BAA0B,QAAQ,gBAAgB;AAC3D,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,kBAAkB,QAA6B,gBAAgB;AACxE,SAASC,MAAM,QAAiB,2BAA2B;AAI3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAACC,QAAa,EAAEC,kBAAsC,EAAU;EACnF,MAAM;IAAEC;EAAkB,CAAC,GAAGF,QAAQ;EACtC,MAAMG,YAAY,GAAGF,kBAAkB,CAACG,iBAAiB,CAACF,GAAG,CAAC;EAC9D,IAAIC,YAAY,IAAI,IAAI,EAAE;IAAA,IAAAE,qBAAA;IACxB,MAAMC,UAAU,IAAAD,qBAAA,GAAGL,QAAQ,CAACO,SAAS,EAAED,UAAU,cAAAD,qBAAA,cAAAA,qBAAA,GAAIL,QAAQ,CAACM,UAAU;IACxE;IACA;IACA,MAAME,GAAG,GAAGC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACT,YAAY,EAAEG,UAAU,CAAC,GACtEH,YAAY,CAACG,UAAU,CAA8B,GACrDO,SAAS;IACb,IAAIL,GAAG,IAAI,IAAI,EAAE,OAAOA,GAAG;IAC3B;IACA,MAAMM,gBAAgB,GAAGL,MAAM,CAACM,MAAM,CAACZ,YAAY,CAAC;IACpD;IACA,IAAIW,gBAAgB,CAACE,MAAM,KAAK,CAAC,EAAE,OAAOxB,KAAK,CAACsB,gBAAgB,CAAC;EACnE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,IAAKH,SAAS,CAAC;MAAEe,gBAAgB,EAAEZ;IAAI,CAAC,CAAC,EAC7CT,QAAQ,EACRC,OAAO,EACP3C,kBACF,CAAC;IACD,MAAMyD,KAAK,GACTI,MAAM,EAAEK,UAAU,CAACX,cAAc,CAAC,KAAK,IAAI,GACvCU,MAAM,CACHE,SAAS,CAAC7E,gBAAgB,CAACU,kBAAkB,CAAC,CAACkD,QAAQ,CAAC,CAAC,CAAC,CAC1DG,KAAK,CAACQ,MAAM,CAACO,OAAO,CAACb,cAAc,EAAE,EAAE,CAAC,CAAC,GAC5C,IAAIvE,SAAS,CAAC6E,MAAM,aAANA,MAAM,cAANA,MAAM,GAAII,MAAM,CAAC;IACrC,IAAIA,MAAM,CAACI,EAAE,CAACZ,KAAK,CAAC,EAAE;MACpB,IAAIK,eAAe,KAAK,IAAI,EAAE,OAAOG,MAAM,CAACD,OAAO,CAAC,CAAC;MACrD,MAAM,IAAI9E,oBAAoB,CAAC,OAAOuE,KAAK,CAACP,QAAQ,CAAC,CAAC,wBAAwBe,MAAM,EAAE,CAAC;IACzF;IACA,OAAOR,KAAK,CAACO,OAAO,CAAC,CAAC;EACxB,CAAC;EAEDM,SAASA,CACPb,KAAiD,EACjDvB,MAA0E,EAC1EqC,OAC4C,EACpC;IACR,IAAI,OAAOd,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACS,UAAU,CAACX,cAAc,CAAC,EAAE;MACjE,OAAO/D,IAAI,CAAC8E,SAAS,CAAC,IAAI,CAACV,eAAe,CAACH,KAAK,EAAEvB,MAAM,EAAEqC,OAAO,CAAC,CAAC;IACrE;IACA,OAAO9E,UAAU,CAAC6E,SAAS,CAAC3D,IAAI,CAAC,IAAI,EAAE8C,KAAK,EAAEvB,MAAM,EAAEqC,OAAO,CAAC;EAChE;AACF,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import coinAmount from './coin-amount.js';
3
3
  import { ArgumentError, IllegalArgumentError } from '../../../utils/errors.js';
4
- import { defaultProtocolParameters, getCachedProtocolParameters, getGasPriceDivisor } from '../protocol-parameters.js';
4
+ import { defaultProtocolParameters, getCachedProtocolParameters, getFloorGasPrice, getGasPriceDivisor } from '../protocol-parameters.js';
5
5
  import { serializeAsIsParam } from './interface.js';
6
6
  import { unwrapProxy } from '../../../utils/wrap-proxy.js';
7
7
  import { formatAmount } from '../../../utils/amount-formatter.js';
@@ -64,9 +64,11 @@ export async function getCachedIncreasedGasPrice(nodeOrProxy, parameters) {
64
64
  const [protocolParameters, demandGasPrice] = await Promise.all([parameters !== null && parameters !== void 0 ? parameters : getCachedProtocolParameters(node), demandEntry.gasPrice]);
65
65
  let gasPrice = demandGasPrice;
66
66
 
67
- // 0n means "the consensus minimum", it is below what the miner of this node accepts
68
- const minerFloor = protocolParameters.minMinerGasPrice > protocolParameters.minGasPrice ? protocolParameters.minMinerGasPrice : 0n;
69
- if (gasPrice < minerFloor) gasPrice = minerFloor;
67
+ // 0n means "the consensus minimum", only a miner asking for more lifts it
68
+ const floorGasPrice = getFloorGasPrice(protocolParameters);
69
+ if (floorGasPrice > protocolParameters.minGasPrice && gasPrice < floorGasPrice) {
70
+ gasPrice = floorGasPrice;
71
+ }
70
72
 
71
73
  // the ceiling goes down by the factor the parameters raise the fee gas by — see
72
74
  // `getGasPriceDivisor`. Counted in thousandths so that a hard fork raising the gas a few percent
@@ -107,11 +109,13 @@ export default {
107
109
  serializeAettos(value, params, {
108
110
  protocolParameters = defaultProtocolParameters
109
111
  }) {
110
- const minGasPrice = protocolParameters.minGasPrice.toString();
111
- if (value == null) return minGasPrice;
112
+ // defaulted and checked against the floor `prepare` applies, for a build that gets no
113
+ // `prepare` — see `getFloorGasPrice`. Provide `protocolParameters` to build for another node
114
+ const floorGasPrice = getFloorGasPrice(protocolParameters).toString();
115
+ if (value == null) return floorGasPrice;
112
116
  if (params[serializeAsIsParam] === true) return value;
113
- if (new BigNumber(value).lt(minGasPrice)) {
114
- throw new IllegalArgumentError(`Gas price ${value} must be bigger than ${minGasPrice}`);
117
+ if (new BigNumber(value).lt(floorGasPrice)) {
118
+ throw new IllegalArgumentError(`Gas price ${value} must be bigger than ${floorGasPrice}`);
115
119
  }
116
120
  return value;
117
121
  }