@polymeshassociation/polymesh-sdk 15.0.1 → 15.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/api/client/Network.d.ts +3 -3
- package/api/client/Network.d.ts.map +1 -1
- package/api/client/Network.js +11 -7
- package/api/client/Network.js.map +1 -1
- package/api/client/Polymesh.d.ts +37 -3
- package/api/client/Polymesh.d.ts.map +1 -1
- package/api/client/Polymesh.js +4 -3
- package/api/client/Polymesh.js.map +1 -1
- package/api/entities/Account.d.ts +4 -0
- package/api/entities/Account.d.ts.map +1 -1
- package/api/entities/Account.js +10 -0
- package/api/entities/Account.js.map +1 -1
- package/api/entities/Asset/Checkpoints/Schedules.d.ts +1 -1
- package/api/entities/Asset/Settlements.d.ts +2 -2
- package/api/entities/Asset/Settlements.js +2 -2
- package/api/entities/DividendDistribution/index.d.ts.map +1 -1
- package/api/entities/DividendDistribution/index.js +2 -2
- package/api/entities/DividendDistribution/index.js.map +1 -1
- package/api/procedures/addAssetRequirement.d.ts +2 -2
- package/api/procedures/addAssetRequirement.d.ts.map +1 -1
- package/api/procedures/addAssetRequirement.js +3 -3
- package/api/procedures/addAssetRequirement.js.map +1 -1
- package/api/procedures/addAssetStat.d.ts +2 -2
- package/api/procedures/addAssetStat.d.ts.map +1 -1
- package/api/procedures/addAssetStat.js +1 -1
- package/api/procedures/addAssetStat.js.map +1 -1
- package/api/procedures/addInstruction.d.ts +4 -4
- package/api/procedures/addInstruction.d.ts.map +1 -1
- package/api/procedures/addInstruction.js +4 -8
- package/api/procedures/addInstruction.js.map +1 -1
- package/api/procedures/addInvestorUniquenessClaim.d.ts +2 -2
- package/api/procedures/addInvestorUniquenessClaim.d.ts.map +1 -1
- package/api/procedures/addInvestorUniquenessClaim.js +6 -4
- package/api/procedures/addInvestorUniquenessClaim.js.map +1 -1
- package/api/procedures/addTransferRestriction.d.ts +2 -2
- package/api/procedures/addTransferRestriction.d.ts.map +1 -1
- package/api/procedures/addTransferRestriction.js +2 -3
- package/api/procedures/addTransferRestriction.js.map +1 -1
- package/api/procedures/claimClassicTicker.d.ts +2 -1
- package/api/procedures/claimClassicTicker.d.ts.map +1 -1
- package/api/procedures/claimClassicTicker.js +3 -3
- package/api/procedures/claimClassicTicker.js.map +1 -1
- package/api/procedures/claimDividends.d.ts +2 -1
- package/api/procedures/claimDividends.d.ts.map +1 -1
- package/api/procedures/claimDividends.js +3 -2
- package/api/procedures/claimDividends.js.map +1 -1
- package/api/procedures/closeOffering.d.ts +2 -2
- package/api/procedures/closeOffering.d.ts.map +1 -1
- package/api/procedures/closeOffering.js +3 -2
- package/api/procedures/closeOffering.js.map +1 -1
- package/api/procedures/configureDividendDistribution.d.ts +3 -3
- package/api/procedures/configureDividendDistribution.d.ts.map +1 -1
- package/api/procedures/configureDividendDistribution.js +3 -4
- package/api/procedures/configureDividendDistribution.js.map +1 -1
- package/api/procedures/consumeAddMultiSigSignerAuthorization.d.ts +2 -2
- package/api/procedures/consumeAddMultiSigSignerAuthorization.d.ts.map +1 -1
- package/api/procedures/consumeAddMultiSigSignerAuthorization.js +3 -4
- package/api/procedures/consumeAddMultiSigSignerAuthorization.js.map +1 -1
- package/api/procedures/consumeAuthorizationRequests.d.ts +2 -2
- package/api/procedures/consumeAuthorizationRequests.d.ts.map +1 -1
- package/api/procedures/consumeAuthorizationRequests.js +8 -4
- package/api/procedures/consumeAuthorizationRequests.js.map +1 -1
- package/api/procedures/consumeJoinOrRotateAuthorization.d.ts +2 -2
- package/api/procedures/consumeJoinOrRotateAuthorization.d.ts.map +1 -1
- package/api/procedures/consumeJoinOrRotateAuthorization.js +8 -7
- package/api/procedures/consumeJoinOrRotateAuthorization.js.map +1 -1
- package/api/procedures/controllerTransfer.d.ts +2 -2
- package/api/procedures/controllerTransfer.d.ts.map +1 -1
- package/api/procedures/controllerTransfer.js +3 -2
- package/api/procedures/controllerTransfer.js.map +1 -1
- package/api/procedures/createAsset.d.ts +2 -2
- package/api/procedures/createAsset.d.ts.map +1 -1
- package/api/procedures/createAsset.js +19 -39
- package/api/procedures/createAsset.js.map +1 -1
- package/api/procedures/createCheckpoint.d.ts +3 -3
- package/api/procedures/createCheckpoint.d.ts.map +1 -1
- package/api/procedures/createCheckpoint.js +3 -4
- package/api/procedures/createCheckpoint.js.map +1 -1
- package/api/procedures/createCheckpointSchedule.d.ts +3 -3
- package/api/procedures/createCheckpointSchedule.d.ts.map +1 -1
- package/api/procedures/createCheckpointSchedule.js +3 -4
- package/api/procedures/createCheckpointSchedule.js.map +1 -1
- package/api/procedures/createGroup.d.ts +3 -3
- package/api/procedures/createGroup.d.ts.map +1 -1
- package/api/procedures/createGroup.js +3 -4
- package/api/procedures/createGroup.js.map +1 -1
- package/api/procedures/createPortfolios.d.ts +3 -2
- package/api/procedures/createPortfolios.d.ts.map +1 -1
- package/api/procedures/createPortfolios.js +4 -6
- package/api/procedures/createPortfolios.js.map +1 -1
- package/api/procedures/createTransactionBatch.d.ts +25 -0
- package/api/procedures/createTransactionBatch.d.ts.map +1 -0
- package/api/procedures/createTransactionBatch.js +118 -0
- package/api/procedures/createTransactionBatch.js.map +1 -0
- package/api/procedures/createVenue.d.ts +3 -2
- package/api/procedures/createVenue.d.ts.map +1 -1
- package/api/procedures/createVenue.js +3 -4
- package/api/procedures/createVenue.js.map +1 -1
- package/api/procedures/deletePortfolio.d.ts +2 -2
- package/api/procedures/deletePortfolio.d.ts.map +1 -1
- package/api/procedures/deletePortfolio.js +3 -2
- package/api/procedures/deletePortfolio.js.map +1 -1
- package/api/procedures/investInOffering.d.ts +2 -2
- package/api/procedures/investInOffering.d.ts.map +1 -1
- package/api/procedures/investInOffering.js +3 -2
- package/api/procedures/investInOffering.js.map +1 -1
- package/api/procedures/inviteAccount.d.ts +3 -2
- package/api/procedures/inviteAccount.d.ts.map +1 -1
- package/api/procedures/inviteAccount.js +3 -4
- package/api/procedures/inviteAccount.js.map +1 -1
- package/api/procedures/inviteExternalAgent.d.ts +3 -3
- package/api/procedures/inviteExternalAgent.d.ts.map +1 -1
- package/api/procedures/inviteExternalAgent.js +6 -10
- package/api/procedures/inviteExternalAgent.js.map +1 -1
- package/api/procedures/issueTokens.d.ts +2 -2
- package/api/procedures/issueTokens.d.ts.map +1 -1
- package/api/procedures/issueTokens.js +3 -3
- package/api/procedures/issueTokens.js.map +1 -1
- package/api/procedures/launchOffering.d.ts +3 -3
- package/api/procedures/launchOffering.d.ts.map +1 -1
- package/api/procedures/launchOffering.js +3 -4
- package/api/procedures/launchOffering.js.map +1 -1
- package/api/procedures/leaveIdentity.d.ts +2 -1
- package/api/procedures/leaveIdentity.d.ts.map +1 -1
- package/api/procedures/leaveIdentity.js +1 -1
- package/api/procedures/leaveIdentity.js.map +1 -1
- package/api/procedures/linkCaDocs.d.ts +2 -2
- package/api/procedures/linkCaDocs.d.ts.map +1 -1
- package/api/procedures/linkCaDocs.js +3 -2
- package/api/procedures/linkCaDocs.js.map +1 -1
- package/api/procedures/modifyAllowance.d.ts +2 -2
- package/api/procedures/modifyAllowance.d.ts.map +1 -1
- package/api/procedures/modifyAllowance.js +3 -2
- package/api/procedures/modifyAllowance.js.map +1 -1
- package/api/procedures/modifyAsset.d.ts +2 -2
- package/api/procedures/modifyAsset.d.ts.map +1 -1
- package/api/procedures/modifyAsset.js +1 -2
- package/api/procedures/modifyAsset.js.map +1 -1
- package/api/procedures/modifyAssetTrustedClaimIssuers.d.ts +2 -2
- package/api/procedures/modifyAssetTrustedClaimIssuers.d.ts.map +1 -1
- package/api/procedures/modifyAssetTrustedClaimIssuers.js +1 -2
- package/api/procedures/modifyAssetTrustedClaimIssuers.js.map +1 -1
- package/api/procedures/modifyCaCheckpoint.d.ts +2 -2
- package/api/procedures/modifyCaCheckpoint.d.ts.map +1 -1
- package/api/procedures/modifyCaCheckpoint.js +19 -3
- package/api/procedures/modifyCaCheckpoint.js.map +1 -1
- package/api/procedures/modifyCaDefaultConfig.d.ts +2 -2
- package/api/procedures/modifyCaDefaultConfig.d.ts.map +1 -1
- package/api/procedures/modifyCaDefaultConfig.js +1 -1
- package/api/procedures/modifyCaDefaultConfig.js.map +1 -1
- package/api/procedures/modifyClaims.d.ts +2 -2
- package/api/procedures/modifyClaims.d.ts.map +1 -1
- package/api/procedures/modifyClaims.js +2 -3
- package/api/procedures/modifyClaims.js.map +1 -1
- package/api/procedures/modifyComplianceRequirement.d.ts +2 -2
- package/api/procedures/modifyComplianceRequirement.d.ts.map +1 -1
- package/api/procedures/modifyComplianceRequirement.js +3 -2
- package/api/procedures/modifyComplianceRequirement.js.map +1 -1
- package/api/procedures/modifyCorporateActionsAgent.d.ts +2 -2
- package/api/procedures/modifyCorporateActionsAgent.d.ts.map +1 -1
- package/api/procedures/modifyCorporateActionsAgent.js +3 -2
- package/api/procedures/modifyCorporateActionsAgent.js.map +1 -1
- package/api/procedures/modifyInstructionAffirmation.d.ts +2 -2
- package/api/procedures/modifyInstructionAffirmation.d.ts.map +1 -1
- package/api/procedures/modifyInstructionAffirmation.js +9 -10
- package/api/procedures/modifyInstructionAffirmation.js.map +1 -1
- package/api/procedures/modifyOfferingTimes.d.ts +2 -2
- package/api/procedures/modifyOfferingTimes.d.ts.map +1 -1
- package/api/procedures/modifyOfferingTimes.js +3 -2
- package/api/procedures/modifyOfferingTimes.js.map +1 -1
- package/api/procedures/modifyPrimaryIssuanceAgent.d.ts +2 -2
- package/api/procedures/modifyPrimaryIssuanceAgent.d.ts.map +1 -1
- package/api/procedures/modifyPrimaryIssuanceAgent.js +3 -2
- package/api/procedures/modifyPrimaryIssuanceAgent.js.map +1 -1
- package/api/procedures/modifySignerPermissions.d.ts +2 -2
- package/api/procedures/modifySignerPermissions.d.ts.map +1 -1
- package/api/procedures/modifySignerPermissions.js +3 -2
- package/api/procedures/modifySignerPermissions.js.map +1 -1
- package/api/procedures/modifyVenue.d.ts +2 -2
- package/api/procedures/modifyVenue.d.ts.map +1 -1
- package/api/procedures/modifyVenue.js +1 -1
- package/api/procedures/modifyVenue.js.map +1 -1
- package/api/procedures/moveFunds.d.ts +2 -2
- package/api/procedures/moveFunds.d.ts.map +1 -1
- package/api/procedures/moveFunds.js +3 -2
- package/api/procedures/moveFunds.js.map +1 -1
- package/api/procedures/payDividends.d.ts +2 -2
- package/api/procedures/payDividends.d.ts.map +1 -1
- package/api/procedures/payDividends.js +3 -2
- package/api/procedures/payDividends.js.map +1 -1
- package/api/procedures/quitCustody.d.ts +2 -2
- package/api/procedures/quitCustody.d.ts.map +1 -1
- package/api/procedures/quitCustody.js +3 -2
- package/api/procedures/quitCustody.js.map +1 -1
- package/api/procedures/quitSubsidy.d.ts +2 -2
- package/api/procedures/quitSubsidy.d.ts.map +1 -1
- package/api/procedures/quitSubsidy.js +3 -2
- package/api/procedures/quitSubsidy.js.map +1 -1
- package/api/procedures/reclaimDividendDistributionFunds.d.ts +2 -2
- package/api/procedures/reclaimDividendDistributionFunds.d.ts.map +1 -1
- package/api/procedures/reclaimDividendDistributionFunds.js +3 -2
- package/api/procedures/reclaimDividendDistributionFunds.js.map +1 -1
- package/api/procedures/redeemTokens.d.ts +2 -2
- package/api/procedures/redeemTokens.d.ts.map +1 -1
- package/api/procedures/redeemTokens.js +3 -2
- package/api/procedures/redeemTokens.js.map +1 -1
- package/api/procedures/registerIdentity.d.ts +3 -2
- package/api/procedures/registerIdentity.d.ts.map +1 -1
- package/api/procedures/registerIdentity.js +3 -4
- package/api/procedures/registerIdentity.js.map +1 -1
- package/api/procedures/removeAssetRequirement.d.ts +2 -2
- package/api/procedures/removeAssetRequirement.d.ts.map +1 -1
- package/api/procedures/removeAssetRequirement.js +3 -3
- package/api/procedures/removeAssetRequirement.js.map +1 -1
- package/api/procedures/removeAssetStat.d.ts +2 -2
- package/api/procedures/removeAssetStat.d.ts.map +1 -1
- package/api/procedures/removeAssetStat.js +3 -2
- package/api/procedures/removeAssetStat.js.map +1 -1
- package/api/procedures/removeCheckpointSchedule.d.ts +2 -2
- package/api/procedures/removeCheckpointSchedule.d.ts.map +1 -1
- package/api/procedures/removeCheckpointSchedule.js +3 -2
- package/api/procedures/removeCheckpointSchedule.js.map +1 -1
- package/api/procedures/removeCorporateAction.d.ts +2 -2
- package/api/procedures/removeCorporateAction.d.ts.map +1 -1
- package/api/procedures/removeCorporateAction.js +3 -2
- package/api/procedures/removeCorporateAction.js.map +1 -1
- package/api/procedures/removeCorporateActionsAgent.d.ts +2 -2
- package/api/procedures/removeCorporateActionsAgent.d.ts.map +1 -1
- package/api/procedures/removeCorporateActionsAgent.js +3 -2
- package/api/procedures/removeCorporateActionsAgent.js.map +1 -1
- package/api/procedures/removeExternalAgent.d.ts +2 -2
- package/api/procedures/removeExternalAgent.d.ts.map +1 -1
- package/api/procedures/removeExternalAgent.js +3 -2
- package/api/procedures/removeExternalAgent.js.map +1 -1
- package/api/procedures/removePrimaryIssuanceAgent.d.ts +2 -2
- package/api/procedures/removePrimaryIssuanceAgent.d.ts.map +1 -1
- package/api/procedures/removePrimaryIssuanceAgent.js +3 -2
- package/api/procedures/removePrimaryIssuanceAgent.js.map +1 -1
- package/api/procedures/removeSecondaryAccounts.d.ts +2 -1
- package/api/procedures/removeSecondaryAccounts.d.ts.map +1 -1
- package/api/procedures/removeSecondaryAccounts.js +3 -2
- package/api/procedures/removeSecondaryAccounts.js.map +1 -1
- package/api/procedures/renamePortfolio.d.ts +2 -2
- package/api/procedures/renamePortfolio.d.ts.map +1 -1
- package/api/procedures/renamePortfolio.js +3 -3
- package/api/procedures/renamePortfolio.js.map +1 -1
- package/api/procedures/rescheduleInstruction.d.ts +2 -1
- package/api/procedures/rescheduleInstruction.d.ts.map +1 -1
- package/api/procedures/rescheduleInstruction.js +3 -3
- package/api/procedures/rescheduleInstruction.js.map +1 -1
- package/api/procedures/reserveTicker.d.ts +3 -3
- package/api/procedures/reserveTicker.d.ts.map +1 -1
- package/api/procedures/reserveTicker.js +3 -4
- package/api/procedures/reserveTicker.js.map +1 -1
- package/api/procedures/setAssetDocuments.d.ts +2 -2
- package/api/procedures/setAssetDocuments.d.ts.map +1 -1
- package/api/procedures/setAssetDocuments.js +1 -2
- package/api/procedures/setAssetDocuments.js.map +1 -1
- package/api/procedures/setAssetRequirements.d.ts +2 -2
- package/api/procedures/setAssetRequirements.d.ts.map +1 -1
- package/api/procedures/setAssetRequirements.js +9 -10
- package/api/procedures/setAssetRequirements.js.map +1 -1
- package/api/procedures/setCustodian.d.ts +3 -3
- package/api/procedures/setCustodian.d.ts.map +1 -1
- package/api/procedures/setCustodian.js +3 -6
- package/api/procedures/setCustodian.js.map +1 -1
- package/api/procedures/setGroupPermissions.d.ts +2 -2
- package/api/procedures/setGroupPermissions.d.ts.map +1 -1
- package/api/procedures/setGroupPermissions.js +3 -2
- package/api/procedures/setGroupPermissions.js.map +1 -1
- package/api/procedures/setPermissionGroup.d.ts +2 -2
- package/api/procedures/setPermissionGroup.d.ts.map +1 -1
- package/api/procedures/setPermissionGroup.js +6 -7
- package/api/procedures/setPermissionGroup.js.map +1 -1
- package/api/procedures/setTransferRestrictions.d.ts +2 -2
- package/api/procedures/setTransferRestrictions.d.ts.map +1 -1
- package/api/procedures/setTransferRestrictions.js +2 -3
- package/api/procedures/setTransferRestrictions.js.map +1 -1
- package/api/procedures/subsidizeAccount.d.ts +3 -2
- package/api/procedures/subsidizeAccount.d.ts.map +1 -1
- package/api/procedures/subsidizeAccount.js +3 -4
- package/api/procedures/subsidizeAccount.js.map +1 -1
- package/api/procedures/toggleFreezeOffering.d.ts +2 -2
- package/api/procedures/toggleFreezeOffering.d.ts.map +1 -1
- package/api/procedures/toggleFreezeOffering.js +17 -18
- package/api/procedures/toggleFreezeOffering.js.map +1 -1
- package/api/procedures/toggleFreezeSecondaryAccounts.d.ts +2 -2
- package/api/procedures/toggleFreezeSecondaryAccounts.d.ts.map +1 -1
- package/api/procedures/toggleFreezeSecondaryAccounts.js +7 -9
- package/api/procedures/toggleFreezeSecondaryAccounts.js.map +1 -1
- package/api/procedures/toggleFreezeTransfers.d.ts +2 -2
- package/api/procedures/toggleFreezeTransfers.d.ts.map +1 -1
- package/api/procedures/toggleFreezeTransfers.js +12 -13
- package/api/procedures/toggleFreezeTransfers.js.map +1 -1
- package/api/procedures/togglePauseRequirements.d.ts +2 -2
- package/api/procedures/togglePauseRequirements.d.ts.map +1 -1
- package/api/procedures/togglePauseRequirements.js +3 -3
- package/api/procedures/togglePauseRequirements.js.map +1 -1
- package/api/procedures/transferAssetOwnership.d.ts +3 -3
- package/api/procedures/transferAssetOwnership.d.ts.map +1 -1
- package/api/procedures/transferAssetOwnership.js +3 -4
- package/api/procedures/transferAssetOwnership.js.map +1 -1
- package/api/procedures/transferPolyx.d.ts +2 -2
- package/api/procedures/transferPolyx.d.ts.map +1 -1
- package/api/procedures/transferPolyx.js +8 -8
- package/api/procedures/transferPolyx.js.map +1 -1
- package/api/procedures/transferTickerOwnership.d.ts +3 -3
- package/api/procedures/transferTickerOwnership.d.ts.map +1 -1
- package/api/procedures/transferTickerOwnership.js +3 -4
- package/api/procedures/transferTickerOwnership.js.map +1 -1
- package/api/procedures/types.d.ts +8 -5
- package/api/procedures/types.d.ts.map +1 -1
- package/api/procedures/types.js.map +1 -1
- package/api/procedures/utils.d.ts +1 -2
- package/api/procedures/utils.d.ts.map +1 -1
- package/api/procedures/utils.js +1 -8
- package/api/procedures/utils.js.map +1 -1
- package/api/procedures/waivePermissions.d.ts +2 -2
- package/api/procedures/waivePermissions.d.ts.map +1 -1
- package/api/procedures/waivePermissions.js +3 -2
- package/api/procedures/waivePermissions.js.map +1 -1
- package/base/Context.d.ts +15 -2
- package/base/Context.d.ts.map +1 -1
- package/base/Context.js +37 -3
- package/base/Context.js.map +1 -1
- package/base/PolymeshError.js +1 -1
- package/base/PolymeshError.js.map +1 -1
- package/base/PolymeshTransaction.d.ts +20 -19
- package/base/PolymeshTransaction.d.ts.map +1 -1
- package/base/PolymeshTransaction.js +19 -12
- package/base/PolymeshTransaction.js.map +1 -1
- package/base/PolymeshTransactionBase.d.ts +70 -35
- package/base/PolymeshTransactionBase.d.ts.map +1 -1
- package/base/PolymeshTransactionBase.js +237 -68
- package/base/PolymeshTransactionBase.js.map +1 -1
- package/base/PolymeshTransactionBatch.d.ts +46 -15
- package/base/PolymeshTransactionBatch.d.ts.map +1 -1
- package/base/PolymeshTransactionBatch.js +107 -18
- package/base/PolymeshTransactionBatch.js.map +1 -1
- package/base/Procedure.d.ts +10 -35
- package/base/Procedure.d.ts.map +1 -1
- package/base/Procedure.js +27 -92
- package/base/Procedure.js.map +1 -1
- package/base/types.d.ts +2 -4
- package/base/types.d.ts.map +1 -1
- package/internal.d.ts +1 -3
- package/internal.d.ts.map +1 -1
- package/internal.js +5 -9
- package/internal.js.map +1 -1
- package/npm-package/polymeshassociation-polymesh-sdk-15.1.0-alpha.1.tgz +0 -0
- package/package.json +1 -1
- package/types/index.d.ts +72 -64
- package/types/index.d.ts.map +1 -1
- package/types/index.js +8 -25
- package/types/index.js.map +1 -1
- package/types/internal.d.ts +58 -101
- package/types/internal.d.ts.map +1 -1
- package/types/internal.js +9 -1
- package/types/internal.js.map +1 -1
- package/utils/conversion.d.ts +1 -1
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js.map +1 -1
- package/utils/internal.d.ts +26 -12
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +100 -24
- package/utils/internal.js.map +1 -1
- package/utils/typeguards.d.ts +2 -2
- package/utils/typeguards.d.ts.map +1 -1
- package/utils/typeguards.js.map +1 -1
- package/api/procedures/modifyDistributionCheckpoint.d.ts +0 -25
- package/api/procedures/modifyDistributionCheckpoint.d.ts.map +0 -1
- package/api/procedures/modifyDistributionCheckpoint.js +0 -60
- package/api/procedures/modifyDistributionCheckpoint.js.map +0 -1
- package/base/PostTransactionValue.d.ts +0 -45
- package/base/PostTransactionValue.d.ts.map +0 -1
- package/base/PostTransactionValue.js +0 -108
- package/base/PostTransactionValue.js.map +0 -1
- package/base/TransactionQueue.d.ts +0 -142
- package/base/TransactionQueue.d.ts.map +0 -1
- package/base/TransactionQueue.js +0 -420
- package/base/TransactionQueue.js.map +0 -1
- package/npm-package/polymeshassociation-polymesh-sdk-15.0.1.tgz +0 -0
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { SubmittableExtrinsic } from '@polkadot/api/types';
|
|
3
|
-
import {
|
|
3
|
+
import { SpRuntimeDispatchError } from "../polkadot/types-lookup.ts";
|
|
4
4
|
import { ISubmittableResult, Signer as PolkadotSigner } from '@polkadot/types/types';
|
|
5
5
|
import BigNumber from 'bignumber.js';
|
|
6
6
|
import { EventEmitter } from 'events';
|
|
7
7
|
import { Context, Identity, PolymeshError } from "../internal";
|
|
8
|
-
import {
|
|
9
|
-
import { BaseTransactionSpec,
|
|
8
|
+
import { GenericPolymeshTransaction, PayingAccountFees, TransactionStatus, UnsubCallback } from "../types";
|
|
9
|
+
import { BaseTransactionSpec, MaybeResolverFunction, TransactionSigningData } from "../types/internal";
|
|
10
10
|
/**
|
|
11
11
|
* Wrapper class for a Polymesh Transaction
|
|
12
12
|
*/
|
|
13
|
-
export declare abstract class PolymeshTransactionBase<
|
|
13
|
+
export declare abstract class PolymeshTransactionBase<ReturnValue = void, TransformedReturnValue = ReturnValue> {
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
|
+
static toTransactionSpec<R, T>(transaction: PolymeshTransactionBase<R, T>): BaseTransactionSpec<R, T>;
|
|
14
18
|
/**
|
|
15
19
|
* current status of the transaction
|
|
16
20
|
*/
|
|
@@ -39,10 +43,6 @@ export declare abstract class PolymeshTransactionBase<Values extends unknown[] =
|
|
|
39
43
|
* number of the block where this transaction resides (status: `Succeeded`, `Failed`)
|
|
40
44
|
*/
|
|
41
45
|
blockNumber?: BigNumber;
|
|
42
|
-
/**
|
|
43
|
-
* whether this transaction failing makes the entire transaction queue fail or not
|
|
44
|
-
*/
|
|
45
|
-
isCritical: boolean;
|
|
46
46
|
/**
|
|
47
47
|
* @hidden
|
|
48
48
|
*
|
|
@@ -53,9 +53,9 @@ export declare abstract class PolymeshTransactionBase<Values extends unknown[] =
|
|
|
53
53
|
/**
|
|
54
54
|
* @hidden
|
|
55
55
|
*
|
|
56
|
-
*
|
|
56
|
+
* function that transforms the transaction's return value before returning it after it is run
|
|
57
57
|
*/
|
|
58
|
-
protected
|
|
58
|
+
protected resolver: MaybeResolverFunction<ReturnValue>;
|
|
59
59
|
/**
|
|
60
60
|
* @hidden
|
|
61
61
|
*
|
|
@@ -77,20 +77,27 @@ export declare abstract class PolymeshTransactionBase<Values extends unknown[] =
|
|
|
77
77
|
/**
|
|
78
78
|
* @hidden
|
|
79
79
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* special rules for calculating them
|
|
80
|
+
* function that transforms the return value to another type. Useful when using the same
|
|
81
|
+
* Procedure for different endpoints which are supposed to return different values
|
|
83
82
|
*/
|
|
84
|
-
protected
|
|
83
|
+
protected transformer?: (result: ReturnValue) => Promise<TransformedReturnValue> | TransformedReturnValue;
|
|
85
84
|
protected context: Context;
|
|
86
85
|
/**
|
|
87
86
|
* @hidden
|
|
87
|
+
* whether the queue has run or not (prevents re-running)
|
|
88
88
|
*/
|
|
89
|
-
|
|
89
|
+
private hasRun;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
91
|
+
* @hidden
|
|
92
92
|
*/
|
|
93
|
-
|
|
93
|
+
constructor(transactionSpec: BaseTransactionSpec<ReturnValue, TransformedReturnValue> & TransactionSigningData, context: Context);
|
|
94
|
+
/**
|
|
95
|
+
* Run the transaction, update its status and return a result if applicable.
|
|
96
|
+
* Certain transactions create Entities on the blockchain, and those Entities are returned
|
|
97
|
+
* for convenience. For example, when running a transaction that creates an Asset, the Asset itself
|
|
98
|
+
* is returned
|
|
99
|
+
*/
|
|
100
|
+
run(): Promise<TransformedReturnValue>;
|
|
94
101
|
/**
|
|
95
102
|
* @hidden
|
|
96
103
|
*
|
|
@@ -105,25 +112,34 @@ export declare abstract class PolymeshTransactionBase<Values extends unknown[] =
|
|
|
105
112
|
*
|
|
106
113
|
* @returns unsubscribe function
|
|
107
114
|
*/
|
|
108
|
-
onStatusChange(listener: (transaction:
|
|
115
|
+
onStatusChange(listener: (transaction: GenericPolymeshTransaction<ReturnValue, TransformedReturnValue>) => void): UnsubCallback;
|
|
109
116
|
/**
|
|
110
|
-
* Retrieve
|
|
111
|
-
*
|
|
117
|
+
* Retrieve a breakdown of the fees required to run this transaction, as well as the Account responsible for paying them
|
|
118
|
+
*
|
|
119
|
+
* @note these values might be inaccurate if the transaction is run at a later time. This can be due to a governance vote or other
|
|
120
|
+
* chain related factors (like modifications to a specific subsidizer relationship or a chain upgrade)
|
|
121
|
+
*/
|
|
122
|
+
getTotalFees(): Promise<PayingAccountFees>;
|
|
123
|
+
/**
|
|
124
|
+
* Subscribe to the results of this transaction being processed by the indexing service (and as such, available to the middleware)
|
|
112
125
|
*
|
|
113
|
-
*
|
|
126
|
+
* @param listener - callback function that will be called whenever the middleware is updated with the latest data.
|
|
127
|
+
* If there is an error (timeout or middleware offline) it will be passed to this callback
|
|
114
128
|
*
|
|
115
|
-
* @note this
|
|
116
|
-
*
|
|
129
|
+
* @note this event will be fired even if the queue fails
|
|
130
|
+
* @returns unsubscribe function
|
|
131
|
+
* @throws if the middleware wasn't enabled when instantiating the SDK client
|
|
117
132
|
*/
|
|
118
|
-
|
|
133
|
+
onProcessedByMiddleware(listener: (err?: PolymeshError) => void): UnsubCallback;
|
|
119
134
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
135
|
+
* Poll the middleware every 2 seconds to see if it has already processed the
|
|
136
|
+
* block that reflects the changes brought on by this transaction being run. If so,
|
|
137
|
+
* emit the corresponding event. After 5 retries (or if the middleware can't be reached),
|
|
138
|
+
* the event is emitted with an error
|
|
123
139
|
*
|
|
124
|
-
* @note
|
|
140
|
+
* @note uses the middleware
|
|
125
141
|
*/
|
|
126
|
-
|
|
142
|
+
private emitWhenMiddlewareIsSynced;
|
|
127
143
|
/**
|
|
128
144
|
* @hidden
|
|
129
145
|
*/
|
|
@@ -133,7 +149,7 @@ export declare abstract class PolymeshTransactionBase<Values extends unknown[] =
|
|
|
133
149
|
* AND the caller is being subsidized by a third party, the transaction can't be executed and trying
|
|
134
150
|
* to do so will result in an error
|
|
135
151
|
*
|
|
136
|
-
* @note this depends on the type of transaction itself (
|
|
152
|
+
* @note this depends on the type of transaction itself (e.g. `staking.bond` can't be subsidized, but `asset.createAsset` can)
|
|
137
153
|
*/
|
|
138
154
|
abstract supportsSubsidy(): boolean;
|
|
139
155
|
/**
|
|
@@ -150,18 +166,37 @@ export declare abstract class PolymeshTransactionBase<Values extends unknown[] =
|
|
|
150
166
|
*/
|
|
151
167
|
protected ignoresSubsidy(): boolean;
|
|
152
168
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
169
|
+
* Return this transaction's protocol fees. These are extra fees charged for
|
|
170
|
+
* specific operations on the chain. Not to be confused with network fees (which
|
|
171
|
+
* depend on the complexity of the operation), protocol fees are set by governance and/or
|
|
172
|
+
* chain upgrades
|
|
156
173
|
*/
|
|
157
|
-
|
|
174
|
+
abstract getProtocolFees(): Promise<BigNumber>;
|
|
158
175
|
/**
|
|
159
176
|
* @hidden
|
|
160
177
|
*/
|
|
161
|
-
protected handleExtrinsicFailure(_resolve: (value: ISubmittableResult | PromiseLike<ISubmittableResult>) => void, reject: (reason?: unknown) => void, error:
|
|
178
|
+
protected handleExtrinsicFailure(_resolve: (value: ISubmittableResult | PromiseLike<ISubmittableResult>) => void, reject: (reason?: unknown) => void, error: SpRuntimeDispatchError, data?: Record<string, unknown>): void;
|
|
162
179
|
/**
|
|
163
180
|
* @hidden
|
|
164
181
|
*/
|
|
165
182
|
protected handleExtrinsicSuccess(resolve: (value: ISubmittableResult | PromiseLike<ISubmittableResult>) => void, _reject: (reason?: unknown) => void, receipt: ISubmittableResult): void;
|
|
183
|
+
/**
|
|
184
|
+
* @hidden
|
|
185
|
+
*
|
|
186
|
+
* Check if balances and allowances (both third party and signing Account)
|
|
187
|
+
* are sufficient to cover this transaction's fees
|
|
188
|
+
*/
|
|
189
|
+
private assertFeesCovered;
|
|
190
|
+
/**
|
|
191
|
+
* @hidden
|
|
192
|
+
*
|
|
193
|
+
* Retrieve the Account that would pay fees for the transaction if it was run at this moment, as well as the total amount that can be
|
|
194
|
+
* charged to it (allowance) in case of a subsidy
|
|
195
|
+
*
|
|
196
|
+
* @note the paying Account might change if, before running the transaction, the caller Account enters (or leaves)
|
|
197
|
+
* a subsidizer relationship. A governance vote or chain upgrade could also cause the value to change between the time
|
|
198
|
+
* this method is called and the time the transaction is run
|
|
199
|
+
*/
|
|
200
|
+
private getPayingAccount;
|
|
166
201
|
}
|
|
167
202
|
//# sourceMappingURL=PolymeshTransactionBase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolymeshTransactionBase.d.ts","sourceRoot":"","sources":["../../src/base/PolymeshTransactionBase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PolymeshTransactionBase.d.ts","sourceRoot":"","sources":["../../src/base/PolymeshTransactionBase.ts"],"names":[],"mappings":"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"}
|
|
@@ -14,17 +14,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.PolymeshTransactionBase = void 0;
|
|
16
16
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
17
|
+
const bluebird_1 = __importDefault(require("bluebird"));
|
|
17
18
|
const events_1 = require("events");
|
|
19
|
+
const lodash_1 = require("lodash");
|
|
18
20
|
const internal_1 = require("../internal");
|
|
21
|
+
const queries_1 = require("../middleware/queries");
|
|
19
22
|
const types_1 = require("../types");
|
|
23
|
+
const internal_2 = require("../types/internal");
|
|
20
24
|
const conversion_1 = require("../utils/conversion");
|
|
21
|
-
const
|
|
25
|
+
const internal_3 = require("../utils/internal");
|
|
22
26
|
/**
|
|
23
27
|
* @hidden
|
|
24
28
|
*/
|
|
25
29
|
var Event;
|
|
26
30
|
(function (Event) {
|
|
27
31
|
Event["StatusChange"] = "StatusChange";
|
|
32
|
+
Event["ProcessedByMiddleware"] = "ProcessedByMiddleware";
|
|
28
33
|
})(Event || (Event = {}));
|
|
29
34
|
/**
|
|
30
35
|
* Wrapper class for a Polymesh Transaction
|
|
@@ -41,31 +46,61 @@ class PolymeshTransactionBase {
|
|
|
41
46
|
/**
|
|
42
47
|
* @hidden
|
|
43
48
|
*
|
|
44
|
-
*
|
|
49
|
+
* internal event emitter to handle status changes
|
|
45
50
|
*/
|
|
46
|
-
this.postValues = [];
|
|
47
|
-
const { postTransactionValues, signingAddress, signer, isCritical, fee, paidForBy } = transactionSpec;
|
|
48
|
-
if (postTransactionValues) {
|
|
49
|
-
this.postValues = postTransactionValues;
|
|
50
|
-
}
|
|
51
51
|
this.emitter = new events_1.EventEmitter();
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
* whether the queue has run or not (prevents re-running)
|
|
55
|
+
*/
|
|
56
|
+
this.hasRun = false;
|
|
57
|
+
const { resolver, transformer, signingAddress, signer, paidForBy } = transactionSpec;
|
|
52
58
|
this.signingAddress = signingAddress;
|
|
53
59
|
this.signer = signer;
|
|
54
|
-
this.isCritical = isCritical;
|
|
55
|
-
this.protocolFee = fee;
|
|
56
60
|
this.context = context;
|
|
57
61
|
this.paidForBy = paidForBy;
|
|
62
|
+
this.transformer = transformer;
|
|
63
|
+
this.resolver = resolver;
|
|
58
64
|
}
|
|
59
65
|
/**
|
|
60
|
-
*
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
68
|
+
static toTransactionSpec(transaction) {
|
|
69
|
+
const { resolver, transformer, paidForBy } = transaction;
|
|
70
|
+
return {
|
|
71
|
+
resolver,
|
|
72
|
+
transformer,
|
|
73
|
+
paidForBy,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Run the transaction, update its status and return a result if applicable.
|
|
78
|
+
* Certain transactions create Entities on the blockchain, and those Entities are returned
|
|
79
|
+
* for convenience. For example, when running a transaction that creates an Asset, the Asset itself
|
|
80
|
+
* is returned
|
|
61
81
|
*/
|
|
62
82
|
run() {
|
|
63
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (this.hasRun) {
|
|
85
|
+
throw new internal_1.PolymeshError({
|
|
86
|
+
code: types_1.ErrorCode.General,
|
|
87
|
+
message: 'Cannot re-run a Transaction',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
64
90
|
try {
|
|
91
|
+
yield this.assertFeesCovered();
|
|
65
92
|
const receipt = yield this.internalRun();
|
|
66
93
|
this.receipt = receipt;
|
|
67
|
-
|
|
94
|
+
const { resolver, transformer = (val) => __awaiter(this, void 0, void 0, function* () { return val; }), } = this;
|
|
95
|
+
let value;
|
|
96
|
+
if ((0, internal_2.isResolverFunction)(resolver)) {
|
|
97
|
+
value = yield resolver(receipt);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
value = resolver;
|
|
101
|
+
}
|
|
68
102
|
this.updateStatus(types_1.TransactionStatus.Succeeded);
|
|
103
|
+
return transformer(value);
|
|
69
104
|
}
|
|
70
105
|
catch (err) {
|
|
71
106
|
const error = err;
|
|
@@ -88,6 +123,16 @@ class PolymeshTransactionBase {
|
|
|
88
123
|
}
|
|
89
124
|
throw error;
|
|
90
125
|
}
|
|
126
|
+
finally {
|
|
127
|
+
this.hasRun = true;
|
|
128
|
+
/*
|
|
129
|
+
* We do not await this promise because it is supposed to run in the background, and
|
|
130
|
+
* any errors encountered are emitted. If the user isn't listening, they shouldn't
|
|
131
|
+
* care about middleware (or other) errors anyway
|
|
132
|
+
*/
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
134
|
+
this.emitWhenMiddlewareIsSynced();
|
|
135
|
+
}
|
|
91
136
|
});
|
|
92
137
|
}
|
|
93
138
|
/**
|
|
@@ -98,14 +143,13 @@ class PolymeshTransactionBase {
|
|
|
98
143
|
*/
|
|
99
144
|
internalRun() {
|
|
100
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
const { signingAddress, signer } = this;
|
|
146
|
+
const { signingAddress, signer, context } = this;
|
|
147
|
+
const nonce = context.getNonce().toNumber();
|
|
102
148
|
this.updateStatus(types_1.TransactionStatus.Unapproved);
|
|
103
149
|
return new Promise((resolve, reject) => {
|
|
104
150
|
const txWithArgs = this.composeTx();
|
|
105
151
|
let settingBlockData = Promise.resolve();
|
|
106
|
-
|
|
107
|
-
// More information can be found at: https://polkadot.js.org/docs/api/cookbook/tx/#how-do-i-take-the-pending-tx-pool-into-account-in-my-nonce
|
|
108
|
-
const gettingUnsub = txWithArgs.signAndSend(signingAddress, { nonce: -1, signer }, receipt => {
|
|
152
|
+
const gettingUnsub = txWithArgs.signAndSend(signingAddress, { nonce, signer }, receipt => {
|
|
109
153
|
const { status } = receipt;
|
|
110
154
|
let isLastCallback = false;
|
|
111
155
|
let unsubscribing = Promise.resolve();
|
|
@@ -119,7 +163,7 @@ class PolymeshTransactionBase {
|
|
|
119
163
|
* is emitted, and at the same time. We do not resolve or reject the containing promise until this
|
|
120
164
|
* one resolves
|
|
121
165
|
*/
|
|
122
|
-
settingBlockData = (0,
|
|
166
|
+
settingBlockData = (0, internal_3.defusePromise)(this.context.polymeshApi.rpc.chain.getBlock(blockHash).then(({ block }) => {
|
|
123
167
|
this.blockHash = (0, conversion_1.hashToString)(blockHash);
|
|
124
168
|
this.blockNumber = (0, conversion_1.u32ToBigNumber)(block.header.number.unwrap());
|
|
125
169
|
// we know that the index has to be set by the time the transaction is included in a block
|
|
@@ -127,7 +171,7 @@ class PolymeshTransactionBase {
|
|
|
127
171
|
this.txIndex = new bignumber_js_1.default(receipt.txIndex);
|
|
128
172
|
}));
|
|
129
173
|
// if the extrinsic failed due to an on-chain error, we should handle it in a special way
|
|
130
|
-
extrinsicFailedEvent =
|
|
174
|
+
[extrinsicFailedEvent] = (0, internal_3.filterEventRecords)(receipt, 'system', 'ExtrinsicFailed', true);
|
|
131
175
|
// extrinsic failed so we can unsubscribe
|
|
132
176
|
isLastCallback = !!extrinsicFailedEvent;
|
|
133
177
|
}
|
|
@@ -146,7 +190,7 @@ class PolymeshTransactionBase {
|
|
|
146
190
|
*/
|
|
147
191
|
let finishing = Promise.resolve();
|
|
148
192
|
if (extrinsicFailedEvent) {
|
|
149
|
-
const {
|
|
193
|
+
const { data } = extrinsicFailedEvent;
|
|
150
194
|
finishing = Promise.all([settingBlockData, unsubscribing]).then(() => {
|
|
151
195
|
this.handleExtrinsicFailure(resolve, reject, data[0]);
|
|
152
196
|
});
|
|
@@ -192,96 +236,139 @@ class PolymeshTransactionBase {
|
|
|
192
236
|
* @returns unsubscribe function
|
|
193
237
|
*/
|
|
194
238
|
onStatusChange(listener) {
|
|
195
|
-
|
|
239
|
+
const { emitter } = this;
|
|
240
|
+
emitter.on(Event.StatusChange, listener);
|
|
196
241
|
return () => {
|
|
197
|
-
|
|
242
|
+
emitter.removeListener(Event.StatusChange, listener);
|
|
198
243
|
};
|
|
199
244
|
}
|
|
200
245
|
/**
|
|
201
|
-
* Retrieve
|
|
202
|
-
* charged to it (allowance). A null allowance means that there is no limit to that amount
|
|
203
|
-
*
|
|
204
|
-
* A null return value signifies that the caller Account would pay the fees
|
|
246
|
+
* Retrieve a breakdown of the fees required to run this transaction, as well as the Account responsible for paying them
|
|
205
247
|
*
|
|
206
|
-
* @note
|
|
207
|
-
* a subsidizer relationship
|
|
248
|
+
* @note these values might be inaccurate if the transaction is run at a later time. This can be due to a governance vote or other
|
|
249
|
+
* chain related factors (like modifications to a specific subsidizer relationship or a chain upgrade)
|
|
208
250
|
*/
|
|
209
|
-
|
|
251
|
+
getTotalFees() {
|
|
210
252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
-
const {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
const subsidyWithAllowance = yield context.accountSubsidy();
|
|
224
|
-
if (!subsidyWithAllowance) {
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
const { subsidy: { subsidizer: account }, allowance, } = subsidyWithAllowance;
|
|
253
|
+
const { signingAddress } = this;
|
|
254
|
+
const composedTx = this.composeTx();
|
|
255
|
+
const paymentInfoPromise = composedTx.paymentInfo(signingAddress);
|
|
256
|
+
const protocol = yield this.getProtocolFees();
|
|
257
|
+
const [payingAccount, { partialFee }] = yield Promise.all([
|
|
258
|
+
this.getPayingAccount(),
|
|
259
|
+
paymentInfoPromise,
|
|
260
|
+
]);
|
|
261
|
+
const { free: balance } = yield payingAccount.account.getBalance();
|
|
262
|
+
const gas = (0, conversion_1.balanceToBigNumber)(partialFee);
|
|
228
263
|
return {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
264
|
+
fees: {
|
|
265
|
+
protocol,
|
|
266
|
+
gas,
|
|
267
|
+
total: protocol.plus(gas),
|
|
268
|
+
},
|
|
269
|
+
payingAccountData: Object.assign(Object.assign({}, payingAccount), { balance }),
|
|
232
270
|
};
|
|
233
271
|
});
|
|
234
272
|
}
|
|
235
273
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
274
|
+
* Subscribe to the results of this transaction being processed by the indexing service (and as such, available to the middleware)
|
|
275
|
+
*
|
|
276
|
+
* @param listener - callback function that will be called whenever the middleware is updated with the latest data.
|
|
277
|
+
* If there is an error (timeout or middleware offline) it will be passed to this callback
|
|
278
|
+
*
|
|
279
|
+
* @note this event will be fired even if the queue fails
|
|
280
|
+
* @returns unsubscribe function
|
|
281
|
+
* @throws if the middleware wasn't enabled when instantiating the SDK client
|
|
282
|
+
*/
|
|
283
|
+
onProcessedByMiddleware(listener) {
|
|
284
|
+
const { context, emitter } = this;
|
|
285
|
+
if (!context.isMiddlewareEnabled()) {
|
|
286
|
+
throw new internal_1.PolymeshError({
|
|
287
|
+
code: types_1.ErrorCode.General,
|
|
288
|
+
message: 'Cannot subscribe without an enabled middleware connection',
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
emitter.on(Event.ProcessedByMiddleware, listener);
|
|
292
|
+
return () => {
|
|
293
|
+
emitter.removeListener(Event.ProcessedByMiddleware, listener);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Poll the middleware every 2 seconds to see if it has already processed the
|
|
298
|
+
* block that reflects the changes brought on by this transaction being run. If so,
|
|
299
|
+
* emit the corresponding event. After 5 retries (or if the middleware can't be reached),
|
|
300
|
+
* the event is emitted with an error
|
|
239
301
|
*
|
|
240
|
-
* @note
|
|
302
|
+
* @note uses the middleware
|
|
241
303
|
*/
|
|
242
|
-
|
|
304
|
+
emitWhenMiddlewareIsSynced() {
|
|
243
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
const {
|
|
245
|
-
let { protocolFee: protocol } = this;
|
|
246
|
-
let composedTx;
|
|
306
|
+
const { context, emitter } = this;
|
|
247
307
|
try {
|
|
248
|
-
|
|
308
|
+
if (!context.isMiddlewareEnabled()) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const blockNumber = yield context.getLatestBlock();
|
|
312
|
+
let done = false;
|
|
313
|
+
yield bluebird_1.default.each((0, lodash_1.range)(6), (i) => __awaiter(this, void 0, void 0, function* () {
|
|
314
|
+
if (done) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
const { data: { latestBlock: { id: processedBlock }, }, } = yield context.queryMiddleware((0, queries_1.latestProcessedBlock)());
|
|
319
|
+
if (blockNumber.lte(processedBlock)) {
|
|
320
|
+
done = true;
|
|
321
|
+
emitter.emit(Event.ProcessedByMiddleware);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
catch (err) {
|
|
326
|
+
/*
|
|
327
|
+
* query errors are swallowed because we wish to query again if we haven't reached the
|
|
328
|
+
* maximum amount of retries
|
|
329
|
+
*/
|
|
330
|
+
}
|
|
331
|
+
if (i === 5) {
|
|
332
|
+
emitter.emit(Event.ProcessedByMiddleware, new internal_1.PolymeshError({
|
|
333
|
+
code: types_1.ErrorCode.MiddlewareError,
|
|
334
|
+
message: `Middleware has not synced after ${i} attempts`,
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
return (0, internal_3.delay)(2000);
|
|
338
|
+
}));
|
|
249
339
|
}
|
|
250
340
|
catch (err) {
|
|
251
|
-
|
|
341
|
+
/* istanbul ignore next: extreme edge case */
|
|
342
|
+
emitter.emit(Event.ProcessedByMiddleware, new internal_1.PolymeshError({
|
|
343
|
+
code: types_1.ErrorCode.UnexpectedError,
|
|
344
|
+
message: err.message || 'Unexpected error',
|
|
345
|
+
}));
|
|
252
346
|
}
|
|
253
|
-
const paymentInfoPromise = composedTx.paymentInfo(signingAddress);
|
|
254
|
-
if (!protocol) {
|
|
255
|
-
protocol = yield this.getProtocolFees();
|
|
256
|
-
}
|
|
257
|
-
const { partialFee } = yield paymentInfoPromise;
|
|
258
|
-
return {
|
|
259
|
-
protocol,
|
|
260
|
-
gas: (0, conversion_1.balanceToBigNumber)(partialFee),
|
|
261
|
-
};
|
|
262
347
|
});
|
|
263
348
|
}
|
|
264
349
|
/**
|
|
265
350
|
* @hidden
|
|
266
351
|
*/
|
|
267
352
|
updateStatus(status) {
|
|
353
|
+
const { emitter } = this;
|
|
268
354
|
this.status = status;
|
|
269
355
|
/* eslint-disable default-case */
|
|
270
356
|
switch (status) {
|
|
271
357
|
case types_1.TransactionStatus.Unapproved:
|
|
272
358
|
case types_1.TransactionStatus.Running:
|
|
273
359
|
case types_1.TransactionStatus.Succeeded: {
|
|
274
|
-
|
|
360
|
+
emitter.emit(Event.StatusChange, this);
|
|
275
361
|
return;
|
|
276
362
|
}
|
|
277
363
|
case types_1.TransactionStatus.Rejected:
|
|
278
364
|
case types_1.TransactionStatus.Aborted:
|
|
279
365
|
case types_1.TransactionStatus.Failed: {
|
|
280
|
-
|
|
366
|
+
emitter.emit(Event.StatusChange, this, this.error);
|
|
281
367
|
}
|
|
282
368
|
}
|
|
283
369
|
/* eslint-enable default-case */
|
|
284
370
|
}
|
|
371
|
+
/* istanbul ignore next: there is no way of reaching this path currently */
|
|
285
372
|
/**
|
|
286
373
|
* @hidden
|
|
287
374
|
*
|
|
@@ -324,6 +411,88 @@ class PolymeshTransactionBase {
|
|
|
324
411
|
handleExtrinsicSuccess(resolve, _reject, receipt) {
|
|
325
412
|
resolve(receipt);
|
|
326
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* @hidden
|
|
416
|
+
*
|
|
417
|
+
* Check if balances and allowances (both third party and signing Account)
|
|
418
|
+
* are sufficient to cover this transaction's fees
|
|
419
|
+
*/
|
|
420
|
+
assertFeesCovered() {
|
|
421
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
422
|
+
const { fees: { total }, payingAccountData, } = yield this.getTotalFees();
|
|
423
|
+
const { type, balance } = payingAccountData;
|
|
424
|
+
if (type === types_1.PayingAccountType.Subsidy) {
|
|
425
|
+
const { allowance } = payingAccountData;
|
|
426
|
+
if (!this.supportsSubsidy()) {
|
|
427
|
+
throw new internal_1.PolymeshError({
|
|
428
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
429
|
+
message: 'This transaction cannot be run by a subsidized Account',
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
if (allowance.lt(total)) {
|
|
433
|
+
throw new internal_1.PolymeshError({
|
|
434
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
435
|
+
message: "Insufficient subsidy allowance to pay this transaction's fees",
|
|
436
|
+
data: {
|
|
437
|
+
allowance,
|
|
438
|
+
fees: total,
|
|
439
|
+
},
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const accountDescriptions = {
|
|
444
|
+
[types_1.PayingAccountType.Caller]: 'caller',
|
|
445
|
+
[types_1.PayingAccountType.Other]: 'paying third party',
|
|
446
|
+
[types_1.PayingAccountType.Subsidy]: 'subsidizer',
|
|
447
|
+
};
|
|
448
|
+
if (balance.lt(total)) {
|
|
449
|
+
throw new internal_1.PolymeshError({
|
|
450
|
+
code: types_1.ErrorCode.InsufficientBalance,
|
|
451
|
+
message: `The ${accountDescriptions[type]} Account does not have enough POLYX balance to pay this transaction's fees`,
|
|
452
|
+
data: {
|
|
453
|
+
balance,
|
|
454
|
+
fees: total,
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* @hidden
|
|
462
|
+
*
|
|
463
|
+
* Retrieve the Account that would pay fees for the transaction if it was run at this moment, as well as the total amount that can be
|
|
464
|
+
* charged to it (allowance) in case of a subsidy
|
|
465
|
+
*
|
|
466
|
+
* @note the paying Account might change if, before running the transaction, the caller Account enters (or leaves)
|
|
467
|
+
* a subsidizer relationship. A governance vote or chain upgrade could also cause the value to change between the time
|
|
468
|
+
* this method is called and the time the transaction is run
|
|
469
|
+
*/
|
|
470
|
+
getPayingAccount() {
|
|
471
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
472
|
+
const { paidForBy, context } = this;
|
|
473
|
+
if (paidForBy) {
|
|
474
|
+
const { account: primaryAccount } = yield paidForBy.getPrimaryAccount();
|
|
475
|
+
return {
|
|
476
|
+
type: types_1.PayingAccountType.Other,
|
|
477
|
+
account: primaryAccount,
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
const subsidyWithAllowance = yield context.accountSubsidy();
|
|
481
|
+
if (!subsidyWithAllowance || this.ignoresSubsidy()) {
|
|
482
|
+
const caller = context.getSigningAccount();
|
|
483
|
+
return {
|
|
484
|
+
account: caller,
|
|
485
|
+
type: types_1.PayingAccountType.Caller,
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
const { subsidy: { subsidizer: account }, allowance, } = subsidyWithAllowance;
|
|
489
|
+
return {
|
|
490
|
+
type: types_1.PayingAccountType.Subsidy,
|
|
491
|
+
account,
|
|
492
|
+
allowance,
|
|
493
|
+
};
|
|
494
|
+
});
|
|
495
|
+
}
|
|
327
496
|
}
|
|
328
497
|
exports.PolymeshTransactionBase = PolymeshTransactionBase;
|
|
329
498
|
//# sourceMappingURL=PolymeshTransactionBase.js.map
|