@aeternity/aepp-sdk 14.1.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aepp-sdk.browser-script.cjs +1 -1
- package/dist/aepp-sdk.browser-script.cjs.map +1 -1
- package/dist/aepp-sdk.browser.cjs +1 -1
- package/dist/aepp-sdk.browser.cjs.map +1 -1
- package/dist/aepp-sdk.cjs +10776 -6350
- package/dist/aepp-sdk.cjs.map +1 -1
- package/es/account/Base.d.ts +6 -1
- package/es/account/Base.js.map +1 -1
- package/es/account/Generalized.d.ts +1 -1
- package/es/account/Generalized.js +7 -1
- package/es/account/Generalized.js.map +1 -1
- package/es/aens.d.ts +10 -2
- package/es/aens.js +10 -2
- package/es/aens.js.map +1 -1
- package/es/apis/middleware/models/index.js.map +1 -1
- package/es/apis/node/models/index.d.ts +405 -79
- package/es/apis/node/models/index.js.map +1 -1
- package/es/apis/node/models/mappers.d.ts +54 -4
- package/es/apis/node/models/mappers.js +1910 -500
- package/es/apis/node/models/mappers.js.map +1 -1
- package/es/apis/node/node.d.ts +28 -6
- package/es/apis/node/node.js +276 -5
- package/es/apis/node/node.js.map +1 -1
- package/es/channel/Contract.d.ts +5 -0
- package/es/channel/Contract.js +8 -2
- package/es/channel/Contract.js.map +1 -1
- package/es/channel/handlers.js +3 -3
- package/es/channel/handlers.js.map +1 -1
- package/es/contract/compiler/Cli.js +6 -2
- package/es/contract/compiler/Cli.js.map +1 -1
- package/es/contract/ga.d.ts +5 -2
- package/es/contract/ga.js +53 -21
- package/es/contract/ga.js.map +1 -1
- package/es/index-browser.d.ts +3 -1
- package/es/index-browser.js +2 -1
- package/es/index-browser.js.map +1 -1
- package/es/tx/builder/constants.d.ts +12 -2
- package/es/tx/builder/constants.js +11 -1
- package/es/tx/builder/constants.js.map +1 -1
- package/es/tx/builder/entry/index.js +6 -0
- package/es/tx/builder/entry/index.js.map +1 -1
- package/es/tx/builder/entry/schema.d.ts +10 -10
- package/es/tx/builder/field-types/ct-version.d.ts +14 -0
- package/es/tx/builder/field-types/ct-version.js +14 -0
- package/es/tx/builder/field-types/ct-version.js.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +9 -7
- package/es/tx/builder/field-types/fee.js +75 -66
- package/es/tx/builder/field-types/fee.js.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +5 -3
- package/es/tx/builder/field-types/gas-limit.js +25 -14
- package/es/tx/builder/field-types/gas-limit.js.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +6 -4
- package/es/tx/builder/field-types/gas-price.js +87 -21
- package/es/tx/builder/field-types/gas-price.js.map +1 -1
- package/es/tx/builder/field-types/interface.d.ts +20 -0
- package/es/tx/builder/field-types/interface.js +17 -1
- package/es/tx/builder/field-types/interface.js.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +3 -2
- package/es/tx/builder/field-types/name-fee.js +6 -0
- package/es/tx/builder/field-types/name-fee.js.map +1 -1
- package/es/tx/builder/field-types/pointers.d.ts +2 -1
- package/es/tx/builder/field-types/pointers.js +6 -2
- package/es/tx/builder/field-types/pointers.js.map +1 -1
- package/es/tx/builder/field-types/transaction.d.ts +4 -1
- package/es/tx/builder/field-types/transaction.js +18 -3
- package/es/tx/builder/field-types/transaction.js.map +1 -1
- package/es/tx/builder/field-types/ttl.d.ts +1 -2
- package/es/tx/builder/field-types/ttl.js +7 -4
- package/es/tx/builder/field-types/ttl.js.map +1 -1
- package/es/tx/builder/field-types/with-formatting.d.ts +1 -1
- package/es/tx/builder/field-types/with-formatting.js +1 -1
- package/es/tx/builder/field-types/with-formatting.js.map +1 -1
- package/es/tx/builder/index.d.ts +13 -0
- package/es/tx/builder/index.js +92 -5
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/protocol-parameters.d.ts +123 -0
- package/es/tx/builder/protocol-parameters.js +519 -0
- package/es/tx/builder/protocol-parameters.js.map +1 -0
- package/es/tx/builder/schema.d.ts +179 -201
- package/es/tx/builder/schema.js +5 -1
- package/es/tx/builder/schema.js.map +1 -1
- package/es/tx/execution-cost.js +5 -5
- package/es/tx/execution-cost.js.map +1 -1
- package/es/tx/transaction-signer.js +2 -2
- package/es/tx/transaction-signer.js.map +1 -1
- package/es/tx/validator.js +4 -4
- package/es/tx/validator.js.map +1 -1
- package/es/utils/wrap-proxy.d.ts +10 -0
- package/es/utils/wrap-proxy.js +18 -0
- package/es/utils/wrap-proxy.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","names":["changeStatus","changeState","notify","emit","disconnect","unpackTx","buildTx","decode","IllegalArgumentError","InsufficientBalanceError","ChannelConnectionError","UnexpectedChannelMessageError","ChannelError","Tag","snakeToPascal","appendSignature","tx","signFn","signatures","encodedTx","SignedTx","payloadTx","result","signatures2","tag","concat","signAndNotify","channel","method","data","signedTx","signed_tx","isError","key","error","handleUnexpectedMessage","_channel","message","state","reject","Object","assign","JSON","stringify","wsMessage","handler","channelOpen","awaitingCompletion","onSuccess","resolve","accepted","errorCode","params","error_code","errorMessage","error_msg","event","codes","map","d","code","includes","awaitingConnection","channelInfoStatus","nextStatus","awaitingChannelCreateTx","awaitingOpenConfirmation","_fsmId","fsm_id","payload","channelClosed","awaitingReestablish","awaitingChannelReestablished","_","message2","state2","awaitingReconnection","_options","role","sign","awaitingOnChainTx","awaitingBlockInclusion","info","type","_channelId","channel_id","awaitingChannelsUpdate","awaitingTxSignRequest","enter","_message$method$match","match","updates","awaitingUpdateConflict","awaitingShutdownTx","awaitingLeave","channelId","closeTx"],"sources":["../../src/channel/handlers.ts"],"sourcesContent":["/* eslint-disable consistent-return */\n/* eslint-disable default-case */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport {\n ChannelState,\n changeStatus,\n changeState,\n notify,\n emit,\n disconnect,\n ChannelMessage,\n ChannelFsm,\n SignTx,\n ChannelStatus,\n ChannelEvents,\n} from './internal.js';\nimport { unpackTx, buildTx } from '../tx/builder/index.js';\nimport { decode, Encoded } from '../utils/encoder.js';\nimport {\n IllegalArgumentError,\n InsufficientBalanceError,\n ChannelConnectionError,\n UnexpectedChannelMessageError,\n ChannelError,\n} from '../utils/errors.js';\nimport type Channel from './Base.js';\nimport { Tag } from '../tx/builder/constants.js';\nimport { snakeToPascal } from '../utils/string.js';\n\nexport async function appendSignature(\n tx: Encoded.Transaction,\n signFn: SignTx,\n): Promise<Encoded.Transaction | number | null> {\n const { signatures, encodedTx } = unpackTx(tx, Tag.SignedTx);\n const payloadTx = buildTx(encodedTx);\n const result = await signFn(payloadTx);\n if (typeof result === 'string') {\n const { signatures: signatures2 } = unpackTx(result, Tag.SignedTx);\n return buildTx({\n tag: Tag.SignedTx,\n signatures: signatures.concat(signatures2),\n encodedTx: decode(payloadTx),\n });\n }\n return result;\n}\n\nexport async function signAndNotify(\n channel: Channel,\n method: string,\n data: {\n tx?: Encoded.Transaction;\n signed_tx?: Encoded.Transaction;\n },\n signFn: SignTx,\n): Promise<boolean> {\n let signedTx;\n if (data.tx != null) signedTx = await signFn(data.tx);\n else if (data.signed_tx != null) signedTx = await appendSignature(data.signed_tx, signFn);\n else throw new ChannelError(\"Can't find transaction in message\");\n const isError = typeof signedTx !== 'string';\n const key = data.tx != null ? 'tx' : 'signed_tx';\n notify(channel, method, isError ? { error: signedTx ?? 1 } : { [key]: signedTx });\n return isError;\n}\n\nexport function handleUnexpectedMessage(\n _channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): ChannelFsm {\n state?.reject?.(\n Object.assign(\n new UnexpectedChannelMessageError(\n `Unexpected message received:\\n\\n${JSON.stringify(message)}`,\n ),\n { wsMessage: message },\n ),\n );\n return { handler: channelOpen };\n}\n\nexport function awaitingCompletion(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n onSuccess?: typeof handleUnexpectedMessage,\n): ChannelFsm {\n if (onSuccess != null && message.method === 'channels.update') {\n return onSuccess(channel, message, state);\n }\n if (message.method === 'channels.conflict') {\n state.resolve({\n accepted: false,\n errorCode: message.params.data.error_code,\n errorMessage: message.params.data.error_msg,\n });\n return { handler: channelOpen };\n }\n if (message.method === 'channels.info') {\n if (message.params.data.event === 'aborted_update') {\n state.resolve({ accepted: false });\n return { handler: channelOpen };\n }\n }\n if (message.error != null) {\n const codes = message.error.data.map((d) => d.code);\n if (codes.includes(1001)) {\n state.reject(new InsufficientBalanceError('Insufficient balance'));\n } else if (codes.includes(1002)) {\n state.reject(new IllegalArgumentError('Amount cannot be negative'));\n } else {\n state.reject(new ChannelConnectionError(message.error.message));\n }\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport function awaitingConnection(\n channel: Channel,\n message: ChannelMessage,\n): ChannelFsm | undefined {\n if (message.method === 'channels.info') {\n const channelInfoStatus: string = message.params.data.event;\n\n let nextStatus: ChannelStatus | null = null;\n if (channelInfoStatus === 'channel_accept') nextStatus = 'accepted';\n if (channelInfoStatus === 'funding_created') nextStatus = 'halfSigned';\n if (nextStatus != null) {\n changeStatus(channel, nextStatus);\n return { handler: awaitingChannelCreateTx };\n }\n\n if (message.params.data.event === 'channel_reestablished') {\n return { handler: awaitingOpenConfirmation };\n }\n if (message.params.data.event === 'fsm_up') {\n channel._fsmId = message.params.data.fsm_id;\n return { handler: awaitingConnection };\n }\n return { handler: awaitingConnection };\n }\n if (message.method === 'channels.error') {\n emit(channel, 'error', new ChannelConnectionError(message?.payload?.message));\n return { handler: channelClosed };\n }\n}\n\nexport async function awaitingReestablish(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm> {\n if (message.method === 'channels.info' && message.params.data.event === 'fsm_up') {\n channel._fsmId = message.params.data.fsm_id;\n return {\n handler: function awaitingChannelReestablished(\n _: Channel,\n message2: ChannelMessage,\n state2: ChannelState,\n ): ChannelFsm | undefined {\n if (\n message2.method === 'channels.info' &&\n message2.params.data.event === 'channel_reestablished'\n )\n return { handler: awaitingOpenConfirmation };\n return handleUnexpectedMessage(channel, message2, state2);\n },\n };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport async function awaitingReconnection(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm> {\n if (message.method === 'channels.info' && message.params.data.event === 'fsm_up') {\n channel._fsmId = message.params.data.fsm_id;\n const { signedTx } = await channel.state();\n changeState(channel, signedTx == null ? '' : buildTx(signedTx));\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport async function awaitingChannelCreateTx(\n channel: Channel,\n message: ChannelMessage,\n): Promise<ChannelFsm | undefined> {\n const tag = channel._options.role === 'initiator' ? 'initiator_sign' : 'responder_sign';\n if (message.method === `channels.sign.${tag}`) {\n await signAndNotify(channel, `channels.${tag}`, message.params.data, async (tx) =>\n channel._options.sign(tag, tx),\n );\n return { handler: awaitingOnChainTx };\n }\n}\n\nexport function awaitingOnChainTx(\n channel: Channel,\n message: ChannelMessage,\n): ChannelFsm | undefined {\n function awaitingBlockInclusion(_: Channel, message2: ChannelMessage): ChannelFsm | undefined {\n if (message2.method === 'channels.info') {\n switch (message2.params.data.event) {\n case 'funding_created':\n case 'own_funding_locked':\n return { handler: awaitingBlockInclusion };\n case 'funding_locked':\n return { handler: awaitingOpenConfirmation };\n }\n }\n if (message2.method === 'channels.on_chain_tx') {\n emit(channel, 'onChainTx', message2.params.data.tx, {\n info: message2.params.data.info,\n type: message2.params.data.type,\n });\n return { handler: awaitingBlockInclusion };\n }\n }\n\n if (message.method === 'channels.on_chain_tx') {\n const { info } = message.params.data;\n const { role } = channel._options;\n if (\n (info === 'funding_signed' && role === 'initiator') ||\n (info === 'funding_created' && role === 'responder')\n ) {\n return { handler: awaitingBlockInclusion };\n }\n }\n if (\n message.method === 'channels.info' &&\n message.params.data.event === 'funding_signed' &&\n channel._options.role === 'initiator'\n ) {\n channel._channelId = message.params.channel_id;\n changeStatus(channel, 'signed');\n return { handler: awaitingOnChainTx };\n }\n}\n\nfunction awaitingOpenConfirmation(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): ChannelFsm | undefined {\n if (message.method === 'channels.info' && message.params.data.event === 'open') {\n channel._channelId = message.params.channel_id;\n return {\n handler: function awaitingChannelsUpdate(\n _: Channel,\n message2: ChannelMessage,\n state2: ChannelState,\n ): ChannelFsm | undefined {\n if (message2.method === 'channels.update') {\n changeState(channel, message2.params.data.state);\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message2, state2);\n },\n };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport async function channelOpen(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm | undefined> {\n switch (message.method) {\n case 'channels.info':\n switch (message.params.data.event) {\n case 'update':\n case 'withdraw_created':\n case 'deposit_created':\n return { handler: awaitingTxSignRequest };\n case 'own_withdraw_locked':\n case 'withdraw_locked':\n case 'own_deposit_locked':\n case 'deposit_locked':\n case 'peer_disconnected':\n case 'channel_reestablished':\n case 'open':\n // TODO: Better handling of peer_disconnected event.\n //\n // We should enter intermediate state where offchain transactions\n // are blocked until channel is reestablished.\n emit(channel, snakeToPascal(message.params.data.event) as keyof ChannelEvents);\n return { handler: channelOpen };\n case 'fsm_up':\n channel._fsmId = message.params.data.fsm_id;\n return { handler: channelOpen };\n case 'timeout':\n case 'close_mutual':\n return { handler: channelOpen };\n case 'closing':\n changeStatus(channel, 'closing');\n return { handler: channelOpen };\n case 'closed_confirmed':\n changeStatus(channel, 'closed');\n return { handler: channelClosed };\n case 'died':\n changeStatus(channel, 'died');\n return { handler: channelClosed };\n case 'shutdown':\n return { handler: channelOpen };\n }\n break;\n case 'channels.on_chain_tx':\n emit(channel, 'onChainTx', message.params.data.tx, {\n info: message.params.data.info,\n type: message.params.data.type,\n });\n return { handler: channelOpen };\n case 'channels.leave':\n // TODO: emit event\n return { handler: channelOpen };\n case 'channels.update':\n changeState(channel, message.params.data.state);\n return { handler: channelOpen };\n case 'channels.sign.shutdown_sign_ack':\n return awaitingTxSignRequest(channel, message, state);\n }\n}\nchannelOpen.enter = (channel: Channel) => {\n changeStatus(channel, 'open');\n};\n\nasync function awaitingTxSignRequest(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm> {\n const [, tag] = message.method.match(/^channels\\.sign\\.([^.]+)$/) ?? [];\n if (tag == null) return handleUnexpectedMessage(channel, message, state);\n const isError = await signAndNotify(channel, `channels.${tag}`, message.params.data, async (tx) =>\n channel._options.sign(tag, tx, { updates: message.params.data.updates }),\n );\n\n function awaitingUpdateConflict(_: Channel, message2: ChannelMessage): ChannelFsm {\n if (message2.error != null) {\n return { handler: awaitingUpdateConflict, state };\n }\n if (message2.method === 'channels.conflict') {\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message2, state);\n }\n return isError ? { handler: awaitingUpdateConflict, state } : { handler: channelOpen };\n}\n\nexport async function awaitingShutdownTx(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm> {\n if (message.method !== 'channels.sign.shutdown_sign') {\n return handleUnexpectedMessage(channel, message, state);\n }\n await signAndNotify(channel, 'channels.shutdown_sign', message.params.data, async (tx) =>\n state.sign(tx),\n );\n return {\n handler(_: Channel, message2: ChannelMessage): ChannelFsm {\n if (message2.method !== 'channels.on_chain_tx') {\n return handleUnexpectedMessage(channel, message2, state);\n }\n // state.resolve(message.params.data.tx)\n return { handler: channelClosed, state };\n },\n state,\n };\n}\n\nexport function awaitingLeave(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): ChannelFsm {\n if (message.method === 'channels.leave') {\n state.resolve({ channelId: message.params.channel_id, signedTx: message.params.data.state });\n disconnect(channel);\n return { handler: channelClosed };\n }\n if (message.method === 'channels.error') {\n state.reject(new ChannelConnectionError(message.data.message));\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport function channelClosed(\n _channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): ChannelFsm {\n if (state == null) return { handler: channelClosed };\n if (message.params.data.event === 'closing') return { handler: channelClosed, state };\n if (message.params.data.info === 'channel_closed') {\n state.closeTx = message.params.data.tx;\n return { handler: channelClosed, state };\n }\n if (message.params.data.event === 'closed_confirmed') {\n state.resolve(state.closeTx);\n return { handler: channelClosed };\n }\n return { handler: channelClosed, state };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAEEA,YAAY,EACZC,WAAW,EACXC,MAAM,EACNC,IAAI,EACJC,UAAU,QAML,eAAe;AACtB,SAASC,QAAQ,EAAEC,OAAO,QAAQ,wBAAwB;AAC1D,SAASC,MAAM,QAAiB,qBAAqB;AACrD,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,sBAAsB,EACtBC,6BAA6B,EAC7BC,YAAY,QACP,oBAAoB;AAE3B,SAASC,GAAG,QAAQ,4BAA4B;AAChD,SAASC,aAAa,QAAQ,oBAAoB;AAElD,OAAO,eAAeC,eAAeA,CACnCC,EAAuB,EACvBC,MAAc,EACgC;EAC9C,MAAM;IAAEC,UAAU;IAAEC;EAAU,CAAC,GAAGd,QAAQ,CAACW,EAAE,EAAEH,GAAG,CAACO,QAAQ,CAAC;EAC5D,MAAMC,SAAS,GAAGf,OAAO,CAACa,SAAS,CAAC;EACpC,MAAMG,MAAM,GAAG,MAAML,MAAM,CAACI,SAAS,CAAC;EACtC,IAAI,OAAOC,MAAM,KAAK,QAAQ,EAAE;IAC9B,MAAM;MAAEJ,UAAU,EAAEK;IAAY,CAAC,GAAGlB,QAAQ,CAACiB,MAAM,EAAET,GAAG,CAACO,QAAQ,CAAC;IAClE,OAAOd,OAAO,CAAC;MACbkB,GAAG,EAAEX,GAAG,CAACO,QAAQ;MACjBF,UAAU,EAAEA,UAAU,CAACO,MAAM,CAACF,WAAW,CAAC;MAC1CJ,SAAS,EAAEZ,MAAM,CAACc,SAAS;IAC7B,CAAC,CAAC;EACJ;EACA,OAAOC,MAAM;AACf;AAEA,OAAO,eAAeI,aAA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qD,IAAI,KAAK,gBAAgB,EAAE;IACjD5C,KAAK,CAAC0D,OAAO,GAAG3D,OAAO,CAACe,MAAM,CAACvB,IAAI,CAACb,EAAE;IACtC,OAAO;MAAE6B,OAAO,EAAEyB,aAAa;MAAEhC;IAAM,CAAC;EAC1C;EACA,IAAID,OAAO,CAACe,MAAM,CAACvB,IAAI,CAAC2B,KAAK,KAAK,kBAAkB,EAAE;IACpDlB,KAAK,CAACW,OAAO,CAACX,KAAK,CAAC0D,OAAO,CAAC;IAC5B,OAAO;MAAEnD,OAAO,EAAEyB;IAAc,CAAC;EACnC;EACA,OAAO;IAAEzB,OAAO,EAAEyB,aAAa;IAAEhC;EAAM,CAAC;AAC1C","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"handlers.js","names":["changeStatus","changeState","notify","emit","disconnect","unpackTx","buildTx","rebuildUnpackedTx","decode","IllegalArgumentError","InsufficientBalanceError","ChannelConnectionError","UnexpectedChannelMessageError","ChannelError","Tag","snakeToPascal","appendSignature","tx","signFn","signatures","encodedTx","SignedTx","payloadTx","result","signatures2","tag","concat","signAndNotify","channel","method","data","signedTx","signed_tx","isError","key","error","handleUnexpectedMessage","_channel","message","state","reject","Object","assign","JSON","stringify","wsMessage","handler","channelOpen","awaitingCompletion","onSuccess","resolve","accepted","errorCode","params","error_code","errorMessage","error_msg","event","codes","map","d","code","includes","awaitingConnection","channelInfoStatus","nextStatus","awaitingChannelCreateTx","awaitingOpenConfirmation","_fsmId","fsm_id","payload","channelClosed","awaitingReestablish","awaitingChannelReestablished","_","message2","state2","awaitingReconnection","_options","role","sign","awaitingOnChainTx","awaitingBlockInclusion","info","type","_channelId","channel_id","awaitingChannelsUpdate","awaitingTxSignRequest","enter","_message$method$match","match","updates","awaitingUpdateConflict","awaitingShutdownTx","awaitingLeave","channelId","closeTx"],"sources":["../../src/channel/handlers.ts"],"sourcesContent":["/* eslint-disable consistent-return */\n/* eslint-disable default-case */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport {\n ChannelState,\n changeStatus,\n changeState,\n notify,\n emit,\n disconnect,\n ChannelMessage,\n ChannelFsm,\n SignTx,\n ChannelStatus,\n ChannelEvents,\n} from './internal.js';\nimport { unpackTx, buildTx, rebuildUnpackedTx } from '../tx/builder/index.js';\nimport { decode, Encoded } from '../utils/encoder.js';\nimport {\n IllegalArgumentError,\n InsufficientBalanceError,\n ChannelConnectionError,\n UnexpectedChannelMessageError,\n ChannelError,\n} from '../utils/errors.js';\nimport type Channel from './Base.js';\nimport { Tag } from '../tx/builder/constants.js';\nimport { snakeToPascal } from '../utils/string.js';\n\nexport async function appendSignature(\n tx: Encoded.Transaction,\n signFn: SignTx,\n): Promise<Encoded.Transaction | number | null> {\n const { signatures, encodedTx } = unpackTx(tx, Tag.SignedTx);\n const payloadTx = rebuildUnpackedTx(encodedTx);\n const result = await signFn(payloadTx);\n if (typeof result === 'string') {\n const { signatures: signatures2 } = unpackTx(result, Tag.SignedTx);\n return buildTx({\n tag: Tag.SignedTx,\n signatures: signatures.concat(signatures2),\n encodedTx: decode(payloadTx),\n });\n }\n return result;\n}\n\nexport async function signAndNotify(\n channel: Channel,\n method: string,\n data: {\n tx?: Encoded.Transaction;\n signed_tx?: Encoded.Transaction;\n },\n signFn: SignTx,\n): Promise<boolean> {\n let signedTx;\n if (data.tx != null) signedTx = await signFn(data.tx);\n else if (data.signed_tx != null) signedTx = await appendSignature(data.signed_tx, signFn);\n else throw new ChannelError(\"Can't find transaction in message\");\n const isError = typeof signedTx !== 'string';\n const key = data.tx != null ? 'tx' : 'signed_tx';\n notify(channel, method, isError ? { error: signedTx ?? 1 } : { [key]: signedTx });\n return isError;\n}\n\nexport function handleUnexpectedMessage(\n _channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): ChannelFsm {\n state?.reject?.(\n Object.assign(\n new UnexpectedChannelMessageError(\n `Unexpected message received:\\n\\n${JSON.stringify(message)}`,\n ),\n { wsMessage: message },\n ),\n );\n return { handler: channelOpen };\n}\n\nexport function awaitingCompletion(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n onSuccess?: typeof handleUnexpectedMessage,\n): ChannelFsm {\n if (onSuccess != null && message.method === 'channels.update') {\n return onSuccess(channel, message, state);\n }\n if (message.method === 'channels.conflict') {\n state.resolve({\n accepted: false,\n errorCode: message.params.data.error_code,\n errorMessage: message.params.data.error_msg,\n });\n return { handler: channelOpen };\n }\n if (message.method === 'channels.info') {\n if (message.params.data.event === 'aborted_update') {\n state.resolve({ accepted: false });\n return { handler: channelOpen };\n }\n }\n if (message.error != null) {\n const codes = message.error.data.map((d) => d.code);\n if (codes.includes(1001)) {\n state.reject(new InsufficientBalanceError('Insufficient balance'));\n } else if (codes.includes(1002)) {\n state.reject(new IllegalArgumentError('Amount cannot be negative'));\n } else {\n state.reject(new ChannelConnectionError(message.error.message));\n }\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport function awaitingConnection(\n channel: Channel,\n message: ChannelMessage,\n): ChannelFsm | undefined {\n if (message.method === 'channels.info') {\n const channelInfoStatus: string = message.params.data.event;\n\n let nextStatus: ChannelStatus | null = null;\n if (channelInfoStatus === 'channel_accept') nextStatus = 'accepted';\n if (channelInfoStatus === 'funding_created') nextStatus = 'halfSigned';\n if (nextStatus != null) {\n changeStatus(channel, nextStatus);\n return { handler: awaitingChannelCreateTx };\n }\n\n if (message.params.data.event === 'channel_reestablished') {\n return { handler: awaitingOpenConfirmation };\n }\n if (message.params.data.event === 'fsm_up') {\n channel._fsmId = message.params.data.fsm_id;\n return { handler: awaitingConnection };\n }\n return { handler: awaitingConnection };\n }\n if (message.method === 'channels.error') {\n emit(channel, 'error', new ChannelConnectionError(message?.payload?.message));\n return { handler: channelClosed };\n }\n}\n\nexport async function awaitingReestablish(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm> {\n if (message.method === 'channels.info' && message.params.data.event === 'fsm_up') {\n channel._fsmId = message.params.data.fsm_id;\n return {\n handler: function awaitingChannelReestablished(\n _: Channel,\n message2: ChannelMessage,\n state2: ChannelState,\n ): ChannelFsm | undefined {\n if (\n message2.method === 'channels.info' &&\n message2.params.data.event === 'channel_reestablished'\n )\n return { handler: awaitingOpenConfirmation };\n return handleUnexpectedMessage(channel, message2, state2);\n },\n };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport async function awaitingReconnection(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm> {\n if (message.method === 'channels.info' && message.params.data.event === 'fsm_up') {\n channel._fsmId = message.params.data.fsm_id;\n const { signedTx } = await channel.state();\n changeState(channel, signedTx == null ? '' : rebuildUnpackedTx(signedTx));\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport async function awaitingChannelCreateTx(\n channel: Channel,\n message: ChannelMessage,\n): Promise<ChannelFsm | undefined> {\n const tag = channel._options.role === 'initiator' ? 'initiator_sign' : 'responder_sign';\n if (message.method === `channels.sign.${tag}`) {\n await signAndNotify(channel, `channels.${tag}`, message.params.data, async (tx) =>\n channel._options.sign(tag, tx),\n );\n return { handler: awaitingOnChainTx };\n }\n}\n\nexport function awaitingOnChainTx(\n channel: Channel,\n message: ChannelMessage,\n): ChannelFsm | undefined {\n function awaitingBlockInclusion(_: Channel, message2: ChannelMessage): ChannelFsm | undefined {\n if (message2.method === 'channels.info') {\n switch (message2.params.data.event) {\n case 'funding_created':\n case 'own_funding_locked':\n return { handler: awaitingBlockInclusion };\n case 'funding_locked':\n return { handler: awaitingOpenConfirmation };\n }\n }\n if (message2.method === 'channels.on_chain_tx') {\n emit(channel, 'onChainTx', message2.params.data.tx, {\n info: message2.params.data.info,\n type: message2.params.data.type,\n });\n return { handler: awaitingBlockInclusion };\n }\n }\n\n if (message.method === 'channels.on_chain_tx') {\n const { info } = message.params.data;\n const { role } = channel._options;\n if (\n (info === 'funding_signed' && role === 'initiator') ||\n (info === 'funding_created' && role === 'responder')\n ) {\n return { handler: awaitingBlockInclusion };\n }\n }\n if (\n message.method === 'channels.info' &&\n message.params.data.event === 'funding_signed' &&\n channel._options.role === 'initiator'\n ) {\n channel._channelId = message.params.channel_id;\n changeStatus(channel, 'signed');\n return { handler: awaitingOnChainTx };\n }\n}\n\nfunction awaitingOpenConfirmation(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): ChannelFsm | undefined {\n if (message.method === 'channels.info' && message.params.data.event === 'open') {\n channel._channelId = message.params.channel_id;\n return {\n handler: function awaitingChannelsUpdate(\n _: Channel,\n message2: ChannelMessage,\n state2: ChannelState,\n ): ChannelFsm | undefined {\n if (message2.method === 'channels.update') {\n changeState(channel, message2.params.data.state);\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message2, state2);\n },\n };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport async function channelOpen(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm | undefined> {\n switch (message.method) {\n case 'channels.info':\n switch (message.params.data.event) {\n case 'update':\n case 'withdraw_created':\n case 'deposit_created':\n return { handler: awaitingTxSignRequest };\n case 'own_withdraw_locked':\n case 'withdraw_locked':\n case 'own_deposit_locked':\n case 'deposit_locked':\n case 'peer_disconnected':\n case 'channel_reestablished':\n case 'open':\n // TODO: Better handling of peer_disconnected event.\n //\n // We should enter intermediate state where offchain transactions\n // are blocked until channel is reestablished.\n emit(channel, snakeToPascal(message.params.data.event) as keyof ChannelEvents);\n return { handler: channelOpen };\n case 'fsm_up':\n channel._fsmId = message.params.data.fsm_id;\n return { handler: channelOpen };\n case 'timeout':\n case 'close_mutual':\n return { handler: channelOpen };\n case 'closing':\n changeStatus(channel, 'closing');\n return { handler: channelOpen };\n case 'closed_confirmed':\n changeStatus(channel, 'closed');\n return { handler: channelClosed };\n case 'died':\n changeStatus(channel, 'died');\n return { handler: channelClosed };\n case 'shutdown':\n return { handler: channelOpen };\n }\n break;\n case 'channels.on_chain_tx':\n emit(channel, 'onChainTx', message.params.data.tx, {\n info: message.params.data.info,\n type: message.params.data.type,\n });\n return { handler: channelOpen };\n case 'channels.leave':\n // TODO: emit event\n return { handler: channelOpen };\n case 'channels.update':\n changeState(channel, message.params.data.state);\n return { handler: channelOpen };\n case 'channels.sign.shutdown_sign_ack':\n return awaitingTxSignRequest(channel, message, state);\n }\n}\nchannelOpen.enter = (channel: Channel) => {\n changeStatus(channel, 'open');\n};\n\nasync function awaitingTxSignRequest(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm> {\n const [, tag] = message.method.match(/^channels\\.sign\\.([^.]+)$/) ?? [];\n if (tag == null) return handleUnexpectedMessage(channel, message, state);\n const isError = await signAndNotify(channel, `channels.${tag}`, message.params.data, async (tx) =>\n channel._options.sign(tag, tx, { updates: message.params.data.updates }),\n );\n\n function awaitingUpdateConflict(_: Channel, message2: ChannelMessage): ChannelFsm {\n if (message2.error != null) {\n return { handler: awaitingUpdateConflict, state };\n }\n if (message2.method === 'channels.conflict') {\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message2, state);\n }\n return isError ? { handler: awaitingUpdateConflict, state } : { handler: channelOpen };\n}\n\nexport async function awaitingShutdownTx(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): Promise<ChannelFsm> {\n if (message.method !== 'channels.sign.shutdown_sign') {\n return handleUnexpectedMessage(channel, message, state);\n }\n await signAndNotify(channel, 'channels.shutdown_sign', message.params.data, async (tx) =>\n state.sign(tx),\n );\n return {\n handler(_: Channel, message2: ChannelMessage): ChannelFsm {\n if (message2.method !== 'channels.on_chain_tx') {\n return handleUnexpectedMessage(channel, message2, state);\n }\n // state.resolve(message.params.data.tx)\n return { handler: channelClosed, state };\n },\n state,\n };\n}\n\nexport function awaitingLeave(\n channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): ChannelFsm {\n if (message.method === 'channels.leave') {\n state.resolve({ channelId: message.params.channel_id, signedTx: message.params.data.state });\n disconnect(channel);\n return { handler: channelClosed };\n }\n if (message.method === 'channels.error') {\n state.reject(new ChannelConnectionError(message.data.message));\n return { handler: channelOpen };\n }\n return handleUnexpectedMessage(channel, message, state);\n}\n\nexport function channelClosed(\n _channel: Channel,\n message: ChannelMessage,\n state: ChannelState,\n): ChannelFsm {\n if (state == null) return { handler: channelClosed };\n if (message.params.data.event === 'closing') return { handler: channelClosed, state };\n if (message.params.data.info === 'channel_closed') {\n state.closeTx = message.params.data.tx;\n return { handler: channelClosed, state };\n }\n if (message.params.data.event === 'closed_confirmed') {\n state.resolve(state.closeTx);\n return { handler: channelClosed };\n }\n return { handler: channelClosed, state };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAEEA,YAAY,EACZC,WAAW,EACXC,MAAM,EACNC,IAAI,EACJC,UAAU,QAML,eAAe;AACtB,SAASC,QAAQ,EAAEC,OAAO,EAAEC,iBAAiB,QAAQ,wBAAwB;AAC7E,SAASC,MAAM,QAAiB,qBAAqB;AACrD,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,sBAAsB,EACtBC,6BAA6B,EAC7BC,YAAY,QACP,oBAAoB;AAE3B,SAASC,GAAG,QAAQ,4BAA4B;AAChD,SAASC,aAAa,QAAQ,oBAAoB;AAElD,OAAO,eAAeC,eAAeA,CACnCC,EAAuB,EACvBC,MAAc,EACgC;EAC9C,MAAM;IAAEC,UAAU;IAAEC;EAAU,CAAC,GAAGf,QAAQ,CAACY,EAAE,EAAEH,GAAG,CAACO,QAAQ,CAAC;EAC5D,MAAMC,SAAS,GAAGf,iBAAiB,CAACa,SAAS,CAAC;EAC9C,MAAMG,MAAM,GAAG,MAAML,MAAM,CAACI,SAAS,CAAC;EACtC,IAAI,OAAOC,MAAM,KAAK,QAAQ,EAAE;IAC9B,MAAM;MAAEJ,UAAU,EAAEK;IAAY,CAAC,GAAGnB,QAAQ,CAACkB,MAAM,EAAET,GAAG,CAACO,QAAQ,CAAC;IAClE,OAAOf,OAAO,CAAC;MACbmB,GAAG,EAAEX,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EAAc,CAAC;EACpD,IAAIjC,OAAO,CAACe,MAAM,CAACvB,IAAI,CAAC2B,KAAK,KAAK,SAAS,EAAE,OAAO;IAAEX,OAAO,EAAEyB,aAAa;IAAEhC;EAAM,CAAC;EACrF,IAAID,OAAO,CAACe,MAAM,CAACvB,IAAI,CAACqD,IAAI,KAAK,gBAAgB,EAAE;IACjD5C,KAAK,CAAC0D,OAAO,GAAG3D,OAAO,CAACe,MAAM,CAACvB,IAAI,CAACb,EAAE;IACtC,OAAO;MAAE6B,OAAO,EAAEyB,aAAa;MAAEhC;IAAM,CAAC;EAC1C;EACA,IAAID,OAAO,CAACe,MAAM,CAACvB,IAAI,CAAC2B,KAAK,KAAK,kBAAkB,EAAE;IACpDlB,KAAK,CAACW,OAAO,CAACX,KAAK,CAAC0D,OAAO,CAAC;IAC5B,OAAO;MAAEnD,OAAO,EAAEyB;IAAc,CAAC;EACnC;EACA,OAAO;IAAEzB,OAAO,EAAEyB,aAAa;IAAEhC;EAAM,CAAC;AAC1C","ignoreList":[]}
|
|
@@ -6,11 +6,11 @@ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a),
|
|
|
6
6
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
7
7
|
import { execFile } from 'child_process';
|
|
8
8
|
import { tmpdir } from 'os';
|
|
9
|
-
import { resolve, dirname, basename } from 'path';
|
|
9
|
+
import { resolve, dirname, basename, relative, isAbsolute } from 'path';
|
|
10
10
|
import { mkdir, writeFile, rm } from 'fs/promises';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
12
12
|
import CompilerBase from './Base.js';
|
|
13
|
-
import { CompilerError, InternalError, UnsupportedVersionError } from '../../utils/errors.js';
|
|
13
|
+
import { CompilerError, IllegalArgumentError, InternalError, UnsupportedVersionError } from '../../utils/errors.js';
|
|
14
14
|
import semverSatisfies from '../../utils/semver-satisfies.js';
|
|
15
15
|
import { ensureError } from '../../utils/other.js';
|
|
16
16
|
export const getPackagePath = () => {
|
|
@@ -159,6 +159,10 @@ async function _saveContractToTmpDir(sourceCode, fileSystem = {}) {
|
|
|
159
159
|
await writeFile(sourceCodePath, sourceCode);
|
|
160
160
|
await Promise.all(Object.entries(fileSystem).map(async ([name, src]) => {
|
|
161
161
|
const p = resolve(path, name);
|
|
162
|
+
const rel = relative(path, p);
|
|
163
|
+
if (isAbsolute(rel) || rel.startsWith('..')) {
|
|
164
|
+
throw new IllegalArgumentError(`Path "${name}" is outside of the temp directory`);
|
|
165
|
+
}
|
|
162
166
|
await mkdir(dirname(p), {
|
|
163
167
|
recursive: true
|
|
164
168
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cli.js","names":["execFile","tmpdir","resolve","dirname","basename","mkdir","writeFile","rm","fileURLToPath","CompilerBase","CompilerError","InternalError","UnsupportedVersionError","semverSatisfies","ensureError","getPackagePath","path","import","meta","url","_path","WeakMap","_ensureCompatibleVersion","_CompilerCli_brand","WeakSet","CompilerCli","constructor","compilerPath","ignoreVersion","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","_classPrivateFieldSet","version","then","versions","error","console","warn","message","compile","_classPrivateFieldGet","compileRes","aci","Promise","all","_assertClassBrand","_runWithStderr","call","generateAci","bytecode","stdout","trimEnd","warnings","stderr","split","slice","map","warning","reg","match","pos","file","line","col","compileBySourceCode","sourceCode","fileSystem","tmp","_saveContractToTmpDir","recursive","JSON","parse","_run","generateAciBySourceCode","validate","includes","validateBySourceCode","verMessage","ver","parameters","pResolve","pReject","randomName","Math","random","toString","sourceCodePath","Object","entries","name","src","p"],"sources":["../../../src/contract/compiler/Cli.ts"],"sourcesContent":["import { execFile } from 'child_process';\nimport { tmpdir } from 'os';\nimport { resolve, dirname, basename } from 'path';\nimport { mkdir, writeFile, rm } from 'fs/promises';\nimport { fileURLToPath } from 'url';\nimport CompilerBase, { Aci, CompileResult } from './Base.js';\nimport { Encoded } from '../../utils/encoder.js';\nimport { CompilerError, InternalError, UnsupportedVersionError } from '../../utils/errors.js';\nimport semverSatisfies from '../../utils/semver-satisfies.js';\nimport { ensureError } from '../../utils/other.js';\n\nexport const getPackagePath = (): string => {\n const path = dirname(fileURLToPath(import.meta.url));\n if (basename(path) === 'dist') return resolve(path, '..');\n if (basename(path) === 'compiler') return resolve(path, '../../..');\n throw new InternalError(\"Can't get package path\");\n};\n\n/**\n * A wrapper around aesophia_cli, available only in Node.js.\n * Requires Erlang installed, assumes that `escript` is available in PATH.\n * @category contract\n */\nexport default class CompilerCli extends CompilerBase {\n readonly #path: string;\n\n readonly #ensureCompatibleVersion;\n\n /**\n * @param compilerPath - A path to aesophia_cli binary, by default uses the integrated one\n * @param options - Options\n * @param options.ignoreVersion - Print warning instead of throwing exception if compiler version\n * is not supported, use with caution\n */\n constructor(\n compilerPath = resolve(getPackagePath(), './bin/aesophia_cli'),\n { ignoreVersion = false }: { ignoreVersion?: boolean } = {},\n ) {\n super();\n this.#path = compilerPath;\n this.#ensureCompatibleVersion = this.version().then((version) => {\n const versions = [version, '8.0.0', '9.0.0'] as const;\n if (!semverSatisfies(...versions)) {\n const error = new UnsupportedVersionError('compiler', ...versions);\n if (ignoreVersion) console.warn(error.message);\n else throw error;\n }\n });\n }\n\n async #runWithStderr(...parameters: string[]): Promise<{ stderr: string; stdout: string }> {\n return new Promise((pResolve, pReject) => {\n execFile('escript', [this.#path, ...parameters], (error, stdout, stderr) => {\n if (error != null) pReject(error);\n else pResolve({ stdout, stderr });\n });\n });\n }\n\n async #run(...parameters: string[]): Promise<string> {\n const { stderr, stdout } = await this.#runWithStderr(...parameters);\n if (stderr !== '') throw new CompilerError(stderr);\n return stdout;\n }\n\n static async #saveContractToTmpDir(\n sourceCode: string,\n fileSystem: Record<string, string> = {},\n ): Promise<string> {\n const randomName = (): string => Math.random().toString(36).slice(2);\n const path = resolve(tmpdir(), `aepp-sdk-js-${randomName()}`);\n await mkdir(path);\n const sourceCodePath = resolve(path, `${randomName()}.aes`);\n await writeFile(sourceCodePath, sourceCode);\n await Promise.all(\n Object.entries(fileSystem).map(async ([name, src]) => {\n const p = resolve(path, name);\n await mkdir(dirname(p), { recursive: true });\n return writeFile(p, src);\n }),\n );\n return sourceCodePath;\n }\n\n async compile(path: string): CompileResult {\n await this.#ensureCompatibleVersion;\n try {\n const [compileRes, aci] = await Promise.all([\n this.#runWithStderr(path),\n this.generateAci(path),\n ]);\n return {\n bytecode: compileRes.stdout.trimEnd() as Encoded.ContractBytearray,\n aci,\n warnings: compileRes.stderr\n .split('Warning in ')\n .slice(1)\n .map((warning) => {\n const reg = /^'(.+)' at line (\\d+), col (\\d+):\\n(.+)$/s;\n const match = warning.match(reg);\n if (match == null) throw new InternalError(`Can't parse compiler output: \"${warning}\"`);\n return {\n message: match[4].trimEnd(),\n pos: {\n ...(match[1] !== path && { file: match[1] }),\n line: +match[2],\n col: +match[3],\n },\n };\n }),\n };\n } catch (error) {\n ensureError(error);\n throw new CompilerError(error.message);\n }\n }\n\n async compileBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): CompileResult {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.compile(tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async generateAci(path: string): Promise<Aci> {\n await this.#ensureCompatibleVersion;\n try {\n return JSON.parse(await this.#run('--no_code', '--create_json_aci', path));\n } catch (error) {\n ensureError(error);\n throw new CompilerError(error.message);\n }\n }\n\n async generateAciBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<Aci> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.generateAci(tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n await this.#ensureCompatibleVersion;\n try {\n return (await this.#run(path, '--validate', bytecode)).includes('Validation successful.');\n } catch (error) {\n return false;\n }\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.validate(bytecode, tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async version(): Promise<string> {\n const verMessage = await this.#run('--version');\n const ver = verMessage.match(/Sophia compiler version ([\\d.]+.*)\\n/)?.[1];\n if (ver == null) throw new CompilerError(\"Can't get compiler version\");\n return ver;\n }\n}\n"],"mappings":";;;;;;AAAA,SAASA,QAAQ,QAAQ,eAAe;AACxC,SAASC,MAAM,QAAQ,IAAI;AAC3B,SAASC,OAAO,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,MAAM;AACjD,SAASC,KAAK,EAAEC,SAAS,EAAEC,EAAE,QAAQ,aAAa;AAClD,SAASC,aAAa,QAAQ,KAAK;AACnC,OAAOC,YAAY,MAA8B,WAAW;AAE5D,SAASC,aAAa,EAAEC,aAAa,EAAEC,uBAAuB,QAAQ,uBAAuB;AAC7F,OAAOC,eAAe,MAAM,iCAAiC;AAC7D,SAASC,WAAW,QAAQ,sBAAsB;AAElD,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAc;EAC1C,MAAMC,IAAI,GAAGb,OAAO,CAACK,aAAa,CAACS,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;EACpD,IAAIf,QAAQ,CAACY,IAAI,CAAC,KAAK,MAAM,EAAE,OAAOd,OAAO,CAACc,IAAI,EAAE,IAAI,CAAC;EACzD,IAAIZ,QAAQ,CAACY,IAAI,CAAC,KAAK,UAAU,EAAE,OAAOd,OAAO,CAACc,IAAI,EAAE,UAAU,CAAC;EACnE,MAAM,IAAIL,aAAa,CAAC,wBAAwB,CAAC;AACnD,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA,IAAAS,KAAA,oBAAAC,OAAA;AAA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","relative","isAbsolute","mkdir","writeFile","rm","fileURLToPath","CompilerBase","CompilerError","IllegalArgumentError","InternalError","UnsupportedVersionError","semverSatisfies","ensureError","getPackagePath","path","import","meta","url","_path","WeakMap","_ensureCompatibleVersion","_CompilerCli_brand","WeakSet","CompilerCli","constructor","compilerPath","ignoreVersion","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","_classPrivateFieldSet","version","then","versions","error","console","warn","message","compile","_classPrivateFieldGet","compileRes","aci","Promise","all","_assertClassBrand","_runWithStderr","call","generateAci","bytecode","stdout","trimEnd","warnings","stderr","split","slice","map","warning","reg","match","pos","file","line","col","compileBySourceCode","sourceCode","fileSystem","tmp","_saveContractToTmpDir","recursive","JSON","parse","_run","generateAciBySourceCode","validate","includes","validateBySourceCode","verMessage","ver","parameters","pResolve","pReject","randomName","Math","random","toString","sourceCodePath","Object","entries","name","src","p","rel","startsWith"],"sources":["../../../src/contract/compiler/Cli.ts"],"sourcesContent":["import { execFile } from 'child_process';\nimport { tmpdir } from 'os';\nimport { resolve, dirname, basename, relative, isAbsolute } from 'path';\nimport { mkdir, writeFile, rm } from 'fs/promises';\nimport { fileURLToPath } from 'url';\nimport CompilerBase, { Aci, CompileResult } from './Base.js';\nimport { Encoded } from '../../utils/encoder.js';\nimport {\n CompilerError,\n IllegalArgumentError,\n InternalError,\n UnsupportedVersionError,\n} from '../../utils/errors.js';\nimport semverSatisfies from '../../utils/semver-satisfies.js';\nimport { ensureError } from '../../utils/other.js';\n\nexport const getPackagePath = (): string => {\n const path = dirname(fileURLToPath(import.meta.url));\n if (basename(path) === 'dist') return resolve(path, '..');\n if (basename(path) === 'compiler') return resolve(path, '../../..');\n throw new InternalError(\"Can't get package path\");\n};\n\n/**\n * A wrapper around aesophia_cli, available only in Node.js.\n * Requires Erlang installed, assumes that `escript` is available in PATH.\n * @category contract\n */\nexport default class CompilerCli extends CompilerBase {\n readonly #path: string;\n\n readonly #ensureCompatibleVersion;\n\n /**\n * @param compilerPath - A path to aesophia_cli binary, by default uses the integrated one\n * @param options - Options\n * @param options.ignoreVersion - Print warning instead of throwing exception if compiler version\n * is not supported, use with caution\n */\n constructor(\n compilerPath = resolve(getPackagePath(), './bin/aesophia_cli'),\n { ignoreVersion = false }: { ignoreVersion?: boolean } = {},\n ) {\n super();\n this.#path = compilerPath;\n this.#ensureCompatibleVersion = this.version().then((version) => {\n const versions = [version, '8.0.0', '9.0.0'] as const;\n if (!semverSatisfies(...versions)) {\n const error = new UnsupportedVersionError('compiler', ...versions);\n if (ignoreVersion) console.warn(error.message);\n else throw error;\n }\n });\n }\n\n async #runWithStderr(...parameters: string[]): Promise<{ stderr: string; stdout: string }> {\n return new Promise((pResolve, pReject) => {\n execFile('escript', [this.#path, ...parameters], (error, stdout, stderr) => {\n if (error != null) pReject(error);\n else pResolve({ stdout, stderr });\n });\n });\n }\n\n async #run(...parameters: string[]): Promise<string> {\n const { stderr, stdout } = await this.#runWithStderr(...parameters);\n if (stderr !== '') throw new CompilerError(stderr);\n return stdout;\n }\n\n static async #saveContractToTmpDir(\n sourceCode: string,\n fileSystem: Record<string, string> = {},\n ): Promise<string> {\n const randomName = (): string => Math.random().toString(36).slice(2);\n const path = resolve(tmpdir(), `aepp-sdk-js-${randomName()}`);\n await mkdir(path);\n const sourceCodePath = resolve(path, `${randomName()}.aes`);\n await writeFile(sourceCodePath, sourceCode);\n await Promise.all(\n Object.entries(fileSystem).map(async ([name, src]) => {\n const p = resolve(path, name);\n const rel = relative(path, p);\n if (isAbsolute(rel) || rel.startsWith('..')) {\n throw new IllegalArgumentError(`Path \"${name}\" is outside of the temp directory`);\n }\n await mkdir(dirname(p), { recursive: true });\n return writeFile(p, src);\n }),\n );\n return sourceCodePath;\n }\n\n async compile(path: string): CompileResult {\n await this.#ensureCompatibleVersion;\n try {\n const [compileRes, aci] = await Promise.all([\n this.#runWithStderr(path),\n this.generateAci(path),\n ]);\n return {\n bytecode: compileRes.stdout.trimEnd() as Encoded.ContractBytearray,\n aci,\n warnings: compileRes.stderr\n .split('Warning in ')\n .slice(1)\n .map((warning) => {\n const reg = /^'(.+)' at line (\\d+), col (\\d+):\\n(.+)$/s;\n const match = warning.match(reg);\n if (match == null) throw new InternalError(`Can't parse compiler output: \"${warning}\"`);\n return {\n message: match[4].trimEnd(),\n pos: {\n ...(match[1] !== path && { file: match[1] }),\n line: +match[2],\n col: +match[3],\n },\n };\n }),\n };\n } catch (error) {\n ensureError(error);\n throw new CompilerError(error.message);\n }\n }\n\n async compileBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): CompileResult {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.compile(tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async generateAci(path: string): Promise<Aci> {\n await this.#ensureCompatibleVersion;\n try {\n return JSON.parse(await this.#run('--no_code', '--create_json_aci', path));\n } catch (error) {\n ensureError(error);\n throw new CompilerError(error.message);\n }\n }\n\n async generateAciBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<Aci> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.generateAci(tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n await this.#ensureCompatibleVersion;\n try {\n return (await this.#run(path, '--validate', bytecode)).includes('Validation successful.');\n } catch (error) {\n return false;\n }\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.validate(bytecode, tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async version(): Promise<string> {\n const verMessage = await this.#run('--version');\n const ver = verMessage.match(/Sophia compiler version ([\\d.]+.*)\\n/)?.[1];\n if (ver == null) throw new CompilerError(\"Can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} from '../tx/builder/index.js';
|
|
6
|
+
import { ProtocolParametersOption } from '../tx/builder/protocol-parameters.js';
|
|
6
7
|
import { Encoded } from '../utils/encoder.js';
|
|
7
8
|
import Contract from './Contract.js';
|
|
8
9
|
import Node from '../Node.js';
|
|
@@ -34,13 +35,15 @@ interface CreateGeneralizedAccountOptions extends BuildTxOptions<Tag.GaAttachTx,
|
|
|
34
35
|
* @param options.fee - GaMetaTx fee, required in Ceres
|
|
35
36
|
* @param options.gasPrice - GaMetaTx gasPrice, required in Ceres
|
|
36
37
|
* @param options.onNode - Node to use
|
|
38
|
+
* @param options.protocolParameters - Consensus parameters the `gasPrice` belongs to, requested
|
|
39
|
+
* from node if not provided
|
|
37
40
|
* @returns Transaction hash
|
|
38
41
|
*/
|
|
39
|
-
export declare function buildAuthTxHash(transaction: Encoded.Transaction, { fee, gasPrice, onNode }: {
|
|
42
|
+
export declare function buildAuthTxHash(transaction: Encoded.Transaction, { fee, gasPrice, onNode, protocolParameters, }: {
|
|
40
43
|
fee?: Int;
|
|
41
44
|
gasPrice?: Int;
|
|
42
45
|
onNode: Node;
|
|
43
|
-
}): Promise<Buffer>;
|
|
46
|
+
} & ProtocolParametersOption): Promise<Buffer>;
|
|
44
47
|
/**
|
|
45
48
|
* Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx
|
|
46
49
|
* @category account generalized
|
package/es/contract/ga.js
CHANGED
|
@@ -3,8 +3,9 @@ import { Buffer as _Buffer } from "buffer";
|
|
|
3
3
|
* Generalized Account module - routines to use generalized account
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { buildContractIdByContractTx,
|
|
6
|
+
import { Tag } from '../tx/builder/constants.js';
|
|
7
|
+
import { buildContractIdByContractTx, rebuildUnpackedTx, buildTxAsync, unpackTx } from '../tx/builder/index.js';
|
|
8
|
+
import { getCachedProtocolParameters } from '../tx/builder/protocol-parameters.js';
|
|
8
9
|
import { hash } from '../utils/crypto.js';
|
|
9
10
|
import { decode, encode, Encoding } from '../utils/encoder.js';
|
|
10
11
|
import { ArgumentError, IllegalArgumentError } from '../utils/errors.js';
|
|
@@ -14,6 +15,7 @@ import { getAccount } from '../chain.js';
|
|
|
14
15
|
import { sendTransaction } from '../send-transaction.js';
|
|
15
16
|
import { packEntry } from '../tx/builder/entry/index.js';
|
|
16
17
|
import { EntryTag } from '../tx/builder/entry/constants.js';
|
|
18
|
+
import { serializeAsIsParam } from '../tx/builder/field-types/interface.js';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Convert current account to GA
|
|
@@ -79,6 +81,40 @@ export async function createGeneralizedAccount(authFnName, args, {
|
|
|
79
81
|
gaContractId: contractId
|
|
80
82
|
});
|
|
81
83
|
}
|
|
84
|
+
// the symbol isn't exported, so only `buildAuthTxHashByGaMetaTx` can set it — kept off the public
|
|
85
|
+
// `buildAuthTxHash` signature rather than advertising an option its callers can't provide
|
|
86
|
+
async function buildAuthTxHashInternal(transaction, {
|
|
87
|
+
fee,
|
|
88
|
+
gasPrice,
|
|
89
|
+
onNode,
|
|
90
|
+
protocolParameters,
|
|
91
|
+
...options
|
|
92
|
+
}) {
|
|
93
|
+
const {
|
|
94
|
+
nodeNetworkId
|
|
95
|
+
} = await onNode.getNodeInfo();
|
|
96
|
+
let payload = hash(concatBuffers([_Buffer.from(nodeNetworkId), decode(transaction)]));
|
|
97
|
+
if (fee == null) throw new ArgumentError('fee', 'provided (in Ceres)', fee);
|
|
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.
|
|
102
|
+
// Not requested at all when there is nothing to check, so that re-deriving the hash of an
|
|
103
|
+
// existing transaction needs no round trip and works on a transaction of another network
|
|
104
|
+
payload = hash(decode(packEntry({
|
|
105
|
+
tag: EntryTag.GaMetaTxAuthData,
|
|
106
|
+
fee,
|
|
107
|
+
gasPrice,
|
|
108
|
+
txHash: encode(payload, Encoding.TxHash),
|
|
109
|
+
...(options[serializeAsIsParam] === true ? {
|
|
110
|
+
[serializeAsIsParam]: true
|
|
111
|
+
} : {
|
|
112
|
+
protocolParameters: protocolParameters !== null && protocolParameters !== void 0 ? protocolParameters : await getCachedProtocolParameters(onNode)
|
|
113
|
+
})
|
|
114
|
+
})));
|
|
115
|
+
return payload;
|
|
116
|
+
}
|
|
117
|
+
|
|
82
118
|
/**
|
|
83
119
|
* Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx payload
|
|
84
120
|
* @category account generalized
|
|
@@ -87,29 +123,22 @@ export async function createGeneralizedAccount(authFnName, args, {
|
|
|
87
123
|
* @param options.fee - GaMetaTx fee, required in Ceres
|
|
88
124
|
* @param options.gasPrice - GaMetaTx gasPrice, required in Ceres
|
|
89
125
|
* @param options.onNode - Node to use
|
|
126
|
+
* @param options.protocolParameters - Consensus parameters the `gasPrice` belongs to, requested
|
|
127
|
+
* from node if not provided
|
|
90
128
|
* @returns Transaction hash
|
|
91
129
|
*/
|
|
92
130
|
export async function buildAuthTxHash(transaction, {
|
|
93
131
|
fee,
|
|
94
132
|
gasPrice,
|
|
95
|
-
onNode
|
|
133
|
+
onNode,
|
|
134
|
+
protocolParameters
|
|
96
135
|
}) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (fee == null) throw new ArgumentError('fee', 'provided (in Ceres)', fee);
|
|
104
|
-
if (gasPrice == null) throw new ArgumentError('gasPrice', 'provided (in Ceres)', gasPrice);
|
|
105
|
-
payload = hash(decode(packEntry({
|
|
106
|
-
tag: EntryTag.GaMetaTxAuthData,
|
|
107
|
-
fee,
|
|
108
|
-
gasPrice,
|
|
109
|
-
txHash: encode(payload, Encoding.TxHash)
|
|
110
|
-
})));
|
|
111
|
-
}
|
|
112
|
-
return payload;
|
|
136
|
+
return buildAuthTxHashInternal(transaction, {
|
|
137
|
+
fee,
|
|
138
|
+
gasPrice,
|
|
139
|
+
onNode,
|
|
140
|
+
protocolParameters
|
|
141
|
+
});
|
|
113
142
|
}
|
|
114
143
|
|
|
115
144
|
/**
|
|
@@ -127,10 +156,13 @@ export async function buildAuthTxHashByGaMetaTx(transaction, {
|
|
|
127
156
|
if (txParams.encodedTx.tag !== Tag.GaMetaTx) {
|
|
128
157
|
throw new ArgumentError('transaction', 'to include GaMetaTx', Tag[txParams.encodedTx.tag]);
|
|
129
158
|
}
|
|
130
|
-
return
|
|
159
|
+
return buildAuthTxHashInternal(rebuildUnpackedTx(txParams.encodedTx.tx.encodedTx), {
|
|
131
160
|
fee: txParams.encodedTx.fee,
|
|
132
161
|
gasPrice: txParams.encodedTx.gasPrice,
|
|
133
|
-
onNode
|
|
162
|
+
onNode,
|
|
163
|
+
// the `gasPrice` of a transaction that already exists, never checked and no parameters
|
|
164
|
+
// requested for it — see `serializeAsIsParam`
|
|
165
|
+
[serializeAsIsParam]: true
|
|
134
166
|
});
|
|
135
167
|
}
|
|
136
168
|
//# sourceMappingURL=ga.js.map
|
package/es/contract/ga.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ga.js","names":["ConsensusProtocolVersion","Tag","buildContractIdByContractTx","buildTx","buildTxAsync","unpackTx","hash","decode","encode","Encoding","ArgumentError","IllegalArgumentError","concatBuffers","Contract","getAccount","sendTransaction","packEntry","EntryTag","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","buildAuthTxHash","fee","gasPrice","nodeNetworkId","consensusProtocolVersion","getNodeInfo","payload","_Buffer","from","Ceres","GaMetaTxAuthData","txHash","TxHash","buildAuthTxHashByGaMetaTx","txParams","SignedTx","encodedTx","GaMetaTx"],"sources":["../../src/contract/ga.ts"],"sourcesContent":["/**\n * Generalized Account module - routines to use generalized account\n */\n\nimport { ConsensusProtocolVersion, Int, Tag } from '../tx/builder/constants.js';\nimport {\n buildContractIdByContractTx,\n buildTx,\n buildTxAsync,\n BuildTxOptions,\n unpackTx,\n} from '../tx/builder/index.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';\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/**\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 * @returns Transaction hash\n */\nexport async function buildAuthTxHash(\n transaction: Encoded.Transaction,\n { fee, gasPrice, onNode }: { fee?: Int; gasPrice?: Int; onNode: Node },\n): Promise<Buffer> {\n const { nodeNetworkId, consensusProtocolVersion } = await onNode.getNodeInfo();\n let payload = hash(concatBuffers([Buffer.from(nodeNetworkId), decode(transaction)]));\n if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {\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 payload = hash(\n decode(\n packEntry({\n tag: EntryTag.GaMetaTxAuthData,\n fee,\n gasPrice,\n txHash: encode(payload, Encoding.TxHash),\n }),\n ),\n );\n }\n return payload;\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 buildAuthTxHash(buildTx(txParams.encodedTx.tx.encodedTx), {\n fee: txParams.encodedTx.fee,\n gasPrice: txParams.encodedTx.gasPrice,\n onNode,\n });\n}\n"],"mappings":";AAAA;AACA;AACA;;AAEA,SAASA,wBAAwB,EAAOC,GAAG,QAAQ,4BAA4B;AAC/E,SACEC,2BAA2B,EAC3BC,OAAO,EACPC,YAAY,EAEZC,QAAQ,QACH,wBAAwB;AAC/B,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,MAAM,eAAe;AAEpC,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,eAAe,QAAgC,wBAAwB;AAEhF,SAASC,SAAS,QAAQ,8BAA8B;AACxD,SAASC,QAAQ,QAAQ,kCAAkC;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,UAAkB,EAClBC,IAAW,EACX;EACEC,SAAS;EACTC,UAAU;EACVC,MAAM;EACNC,QAAQ;EACRC,GAAG;EACHC,cAAc;EACdC,UAAU;EACVC,UAAU;EACV,GAAGC;AAC4B,CAAC,EAQlC;EAAA,IAAAC,iBAAA;EACA,MAAMC,OAAO,GAAGV,SAAS,CAACW,OAAO;EACjC,IAAI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,MAAM,IAAI9D,aAAa,CAAC,aAAa,EAAE,qBAAqB,EAAET,GAAG,CAACoE,QAAQ,CAACE,SAAS,CAACjC,GAAG,CAAC,CAAC;EAC5F;EACA,OAAOiB,eAAe,CAACpD,OAAO,CAACkE,QAAQ,CAACE,SAAS,CAACnC,EAAE,CAACmC,SAAS,CAAC,EAAE;IAC/Df,GAAG,EAAEa,QAAQ,CAACE,SAAS,CAACf,GAAG;IAC3BC,QAAQ,EAAEY,QAAQ,CAACE,SAAS,CAACd,QAAQ;IACrClC;EACF,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` 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,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,MAAM,eAAe;AAEpC,SAASC,UA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SAAS,CAACd,QAAQ;IACrClC,MAAM;IACN;IACA;IACA,CAACN,kBAAkB,GAAG;EACxB,CAAC,CAAC;AACJ","ignoreList":[]}
|
package/es/index-browser.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export { verifyMessageSignature as verifyMessage } from './utils/crypto.js';
|
|
|
19
19
|
export { signJwt, unpackJwt, verifyJwt, isJwt, ensureJwt } from './utils/jwt.js';
|
|
20
20
|
export type { Jwt } from './utils/jwt.js';
|
|
21
21
|
export { toBytes } from './utils/bytes.js';
|
|
22
|
-
export { buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx, } from './tx/builder/index.js';
|
|
22
|
+
export { buildTx, buildTxAsync, buildTxHash, rebuildUnpackedTx, unpackTx, buildContractIdByContractTx, } from './tx/builder/index.js';
|
|
23
23
|
export { buildContractId, oracleQueryId, produceNameId, commitmentHash, readInt, isName, ensureName, getDefaultPointerKey, getMinimumNameFee, computeBidFee, computeAuctionEndBlock, isAuctionName, } from './tx/builder/helpers.js';
|
|
24
24
|
/**
|
|
25
25
|
* @category contract
|
|
@@ -33,6 +33,8 @@ 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';
|
|
37
|
+
export type { ProtocolParameters, ProtocolParametersOption, } from './tx/builder/protocol-parameters.js';
|
|
36
38
|
export { ORACLE_TTL_TYPES } from './tx/builder/schema.js';
|
|
37
39
|
export { DelegationTag } from './tx/builder/delegation/schema.js';
|
|
38
40
|
export { packDelegation, unpackDelegation } from './tx/builder/delegation/index.js';
|
package/es/index-browser.js
CHANGED
|
@@ -18,7 +18,7 @@ export { hashMessage as messageToHash } from './utils/crypto.js';
|
|
|
18
18
|
export { verifyMessageSignature as verifyMessage } from './utils/crypto.js';
|
|
19
19
|
export { signJwt, unpackJwt, verifyJwt, isJwt, ensureJwt } from './utils/jwt.js';
|
|
20
20
|
export { toBytes } from './utils/bytes.js';
|
|
21
|
-
export { buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx } from './tx/builder/index.js';
|
|
21
|
+
export { buildTx, buildTxAsync, buildTxHash, rebuildUnpackedTx, unpackTx, buildContractIdByContractTx } from './tx/builder/index.js';
|
|
22
22
|
export { buildContractId, oracleQueryId, produceNameId, commitmentHash, readInt, isName, ensureName, getDefaultPointerKey, getMinimumNameFee, computeBidFee, computeAuctionEndBlock, isAuctionName } from './tx/builder/helpers.js';
|
|
23
23
|
/**
|
|
24
24
|
* @category contract
|
|
@@ -31,6 +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
35
|
// TODO: move to constants
|
|
35
36
|
export { ORACLE_TTL_TYPES } from './tx/builder/schema.js';
|
|
36
37
|
export { DelegationTag } from './tx/builder/delegation/schema.js';
|
package/es/index-browser.js.map
CHANGED
|
@@ -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","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","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 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';\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,mBAAmB,EACnBC,QAAQ,EACRC,mBAAmB,EACnBC,WAAW,EACXC,OAAO,EACPC,WAAW,QACN,YAAY;AACnB,SAASC,cAAc,EAAEC,eAAe,QAAQ,uBAAuB;AACvE,SACEC,cAAc,EACdC,aAAa,EACbC,SAAS,EACTC,OAAO,EACPC,cAAc,EACdC,IAAI,EACJC,eAAe,EACfC,WAAW,EACXC,sBAAsB,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AC1BC,wBAAwB,EACxBC,iBAAiB,EACjBC,sBAAsB,EACtBC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,EACTC,wBAAwB,EACxBC,wBAAwB,EACxBC,mBAAmB,EACnBC,uBAAuB,EACvBC,UAAU,EACVC,aAAa,EACbC,iBAAiB,EACjBC,uBAAuB,EACvBC,uBAAuB,EACvBC,wBAAwB,EACxBC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,EACpBC,wBAAwB,EACxBC,qBAAqB,EACrBC,wBAAwB,EACxBC,gBAAgB,EAChBC,sBAAsB,EACtBC,wBAAwB,EACxBC,6BAA6B,EAC7BC,2BAA2B,EAC3BC,wBAAwB,EACxBC,oBAAoB,EACpBC,qBAAqB,EACrBC,sBAAsB,EACtBC,qBAAqB,EACrBC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,uBAAuB,EACvBC,wBAAwB,EACxBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,uBAAuB,EACvBC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,oBAAoB,EACpBC,2BAA2B,EAC3BC,sBAAsB,EACtBC,sBAAsB,EACtBC,sBAAsB,EACtBC,kBAAkB,EAClBC,iBAAiB,EACjBC,WAAW,EACXC,kBAAkB,EAClBC,WAAW,EACXC,kBAAkB,EAClBC,qBAAqB,EACrBC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EACrBC,sBAAsB,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","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,WAAW,EACXC,mBAAmB,EACnBC,QAAQ,EACRC,mBAAmB,EACnBC,WAAW,EACXC,OAAO,EACPC,WAAW,QACN,YAAY;AACnB,SAASC,cAAc,EAAEC,eAAe,QAAQ,uBAAuB;AACvE,SACEC,cAAc,EACdC,aAAa,EACbC,SAAS,EACTC,OAAO,EACPC,cAAc,EACdC,IAAI,EACJC,eAAe,EACfC,WAAW,EACXC,sBAAsB,QACjB,mBAAmB;AAC1B;AACA;AACA;AACA;AACA,SAASF,eAAe,IAAIG,MAAM,QAAQ,mBAAmB;AAC7D;AACA;AAC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B,EACjBC,sBAAsB,EACtBC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,EACTC,wBAAwB,EACxBC,wBAAwB,EACxBC,mBAAmB,EACnBC,uBAAuB,EACvBC,UAAU,EACVC,aAAa,EACbC,iBAAiB,EACjBC,uBAAuB,EACvBC,uBAAuB,EACvBC,wBAAwB,EACxBC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,EACpBC,wBAAwB,EACxBC,qBAAqB,EACrBC,wBAAwB,EACxBC,gBAAgB,EAChBC,sBAAsB,EACtBC,wBAAwB,EACxBC,6BAA6B,EAC7BC,2BAA2B,EAC3BC,wBAAwB,EACxBC,oBAAoB,EACpBC,qBAAqB,EACrBC,sBAAsB,EACtBC,qBAAqB,EACrBC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,uBAAuB,EACvBC,wBAAwB,EACxBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,uBAAuB,EACvBC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,oBAAoB,EACpBC,2BAA2B,EAC3BC,sBAAsB,EACtBC,sBAAsB,EACtBC,sBAAsB,EACtBC,kBAAkB,EAClBC,iBAAiB,EACjBC,WAAW,EACXC,kBAAkB,EAClBC,WAAW,EACXC,kBAAkB,EAClBC,qBAAqB,EACrBC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EACrBC,sBAAsB,EACtBC,kBAAkB,QACb,mBAAmB","ignoreList":[]}
|
|
@@ -7,8 +7,13 @@ export declare const DRY_RUN_ACCOUNT: {
|
|
|
7
7
|
readonly amount: 100000000000000000000000000000000000n;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
+
* The maximum gas of a generalized account authentication function as it was at the moment of the
|
|
11
|
+
* SDK release. It is a node policy setting rather than a consensus parameter.
|
|
10
12
|
* @category account generalized
|
|
11
|
-
* @deprecated transaction builder
|
|
13
|
+
* @deprecated the transaction builder ensures that gas doesn't exceed the maximum by itself, and a
|
|
14
|
+
* node may accept another maximum than this constant. Use
|
|
15
|
+
* `(await getCachedProtocolParameters(node)).maxAuthFunGas` for the value the connected node
|
|
16
|
+
* reports, or `defaultProtocolParameters.maxAuthFunGas` for this one.
|
|
12
17
|
*/
|
|
13
18
|
export declare const MAX_AUTH_FUN_GAS = 50000;
|
|
14
19
|
/**
|
|
@@ -20,7 +25,11 @@ export type Int = number | string | BigNumber;
|
|
|
20
25
|
*/
|
|
21
26
|
export type AensName = `${string}.chain`;
|
|
22
27
|
/**
|
|
28
|
+
* The consensus minimum gas price as it was at the moment of the SDK release.
|
|
23
29
|
* @category transaction builder
|
|
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.
|
|
24
33
|
*/
|
|
25
34
|
export declare const MIN_GAS_PRICE = 1000000000;
|
|
26
35
|
/**
|
|
@@ -61,7 +70,8 @@ export declare const NAME_BID_RANGES: {
|
|
|
61
70
|
* @category chain
|
|
62
71
|
*/
|
|
63
72
|
export declare enum ConsensusProtocolVersion {
|
|
64
|
-
Ceres = 6
|
|
73
|
+
Ceres = 6,
|
|
74
|
+
Arcus = 7
|
|
65
75
|
}
|
|
66
76
|
/**
|
|
67
77
|
* @category contract
|