@polymeshassociation/polymesh-sdk 31.1.0-beta.2 → 31.1.0-beta.20
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/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +4 -2
- package/api/client/Assets.d.ts +15 -0
- package/api/client/Assets.d.ts.map +1 -1
- package/api/client/Assets.js +36 -5
- package/api/client/Assets.js.map +1 -1
- package/api/client/Claims.d.ts +10 -13
- package/api/client/Claims.d.ts.map +1 -1
- package/api/client/Claims.js +5 -2
- package/api/client/Claims.js.map +1 -1
- package/api/client/Network.d.ts +27 -5
- package/api/client/Network.d.ts.map +1 -1
- package/api/client/Network.js +19 -2
- package/api/client/Network.js.map +1 -1
- package/api/client/Polymesh.d.ts.map +1 -1
- package/api/client/Polymesh.js +5 -6
- package/api/client/Polymesh.js.map +1 -1
- package/api/client/Staking.d.ts +200 -5
- package/api/client/Staking.d.ts.map +1 -1
- package/api/client/Staking.js +422 -1
- package/api/client/Staking.js.map +1 -1
- package/api/client/types.d.ts +284 -12
- package/api/client/types.d.ts.map +1 -1
- package/api/client/types.js +23 -1
- package/api/client/types.js.map +1 -1
- package/api/entities/Account/MultiSig/index.d.ts +8 -4
- package/api/entities/Account/MultiSig/index.d.ts.map +1 -1
- package/api/entities/Account/MultiSig/index.js +6 -2
- package/api/entities/Account/MultiSig/index.js.map +1 -1
- package/api/entities/Account/Staking/index.d.ts +48 -3
- package/api/entities/Account/Staking/index.d.ts.map +1 -1
- package/api/entities/Account/Staking/index.js +80 -3
- package/api/entities/Account/Staking/index.js.map +1 -1
- package/api/entities/Account/index.d.ts +34 -9
- package/api/entities/Account/index.d.ts.map +1 -1
- package/api/entities/Account/index.js +83 -31
- package/api/entities/Account/index.js.map +1 -1
- package/api/entities/Account/types.d.ts +1 -1
- package/api/entities/Asset/Base/BaseAsset.d.ts +20 -1
- package/api/entities/Asset/Base/BaseAsset.d.ts.map +1 -1
- package/api/entities/Asset/Base/BaseAsset.js +5 -1
- package/api/entities/Asset/Base/BaseAsset.js.map +1 -1
- package/api/entities/Asset/Base/Settlements/index.d.ts.map +1 -1
- package/api/entities/Asset/Base/Settlements/index.js +23 -6
- package/api/entities/Asset/Base/Settlements/index.js.map +1 -1
- package/api/entities/Asset/Fungible/AssetHolders/index.d.ts +16 -1
- package/api/entities/Asset/Fungible/AssetHolders/index.d.ts.map +1 -1
- package/api/entities/Asset/Fungible/AssetHolders/index.js +16 -0
- package/api/entities/Asset/Fungible/AssetHolders/index.js.map +1 -1
- package/api/entities/Asset/Fungible/index.d.ts +68 -5
- package/api/entities/Asset/Fungible/index.d.ts.map +1 -1
- package/api/entities/Asset/Fungible/index.js +63 -2
- package/api/entities/Asset/Fungible/index.js.map +1 -1
- package/api/entities/Asset/NonFungible/AssetHolders/index.d.ts +15 -6
- package/api/entities/Asset/NonFungible/AssetHolders/index.d.ts.map +1 -1
- package/api/entities/Asset/NonFungible/AssetHolders/index.js +17 -0
- package/api/entities/Asset/NonFungible/AssetHolders/index.js.map +1 -1
- package/api/entities/Asset/NonFungible/Nft.d.ts +34 -2
- package/api/entities/Asset/NonFungible/Nft.d.ts.map +1 -1
- package/api/entities/Asset/NonFungible/Nft.js +34 -1
- package/api/entities/Asset/NonFungible/Nft.js.map +1 -1
- package/api/entities/Asset/NonFungible/NftCollection.d.ts +56 -5
- package/api/entities/Asset/NonFungible/NftCollection.d.ts.map +1 -1
- package/api/entities/Asset/NonFungible/NftCollection.js +54 -2
- package/api/entities/Asset/NonFungible/NftCollection.js.map +1 -1
- package/api/entities/Asset/types.d.ts +69 -1
- package/api/entities/Asset/types.d.ts.map +1 -1
- package/api/entities/Asset/types.js +7 -1
- package/api/entities/Asset/types.js.map +1 -1
- package/api/entities/AuthorizationRequest.js +1 -1
- package/api/entities/AuthorizationRequest.js.map +1 -1
- package/api/entities/Checkpoint.js +1 -1
- package/api/entities/Checkpoint.js.map +1 -1
- package/api/entities/CheckpointSchedule/index.js +1 -1
- package/api/entities/CheckpointSchedule/index.js.map +1 -1
- package/api/entities/CorporateActionBase/index.js +1 -1
- package/api/entities/CorporateActionBase/index.js.map +1 -1
- package/api/entities/CustomPermissionGroup.js +1 -1
- package/api/entities/CustomPermissionGroup.js.map +1 -1
- package/api/entities/DividendDistribution/index.d.ts +8 -4
- package/api/entities/DividendDistribution/index.d.ts.map +1 -1
- package/api/entities/DividendDistribution/index.js +6 -2
- package/api/entities/DividendDistribution/index.js.map +1 -1
- package/api/entities/Identity/AssetPermissions.d.ts +7 -6
- package/api/entities/Identity/AssetPermissions.d.ts.map +1 -1
- package/api/entities/Identity/AssetPermissions.js +5 -2
- package/api/entities/Identity/AssetPermissions.js.map +1 -1
- package/api/entities/Identity/IdentityAuthorizations.d.ts +5 -0
- package/api/entities/Identity/IdentityAuthorizations.d.ts.map +1 -1
- package/api/entities/Identity/IdentityAuthorizations.js +5 -0
- package/api/entities/Identity/IdentityAuthorizations.js.map +1 -1
- package/api/entities/Identity/Portfolios.js +1 -1
- package/api/entities/Identity/Portfolios.js.map +1 -1
- package/api/entities/Identity/index.d.ts +50 -7
- package/api/entities/Identity/index.d.ts.map +1 -1
- package/api/entities/Identity/index.js +76 -9
- package/api/entities/Identity/index.js.map +1 -1
- package/api/entities/Instruction/index.js +1 -1
- package/api/entities/Instruction/index.js.map +1 -1
- package/api/entities/MetadataEntry/index.js +1 -1
- package/api/entities/MetadataEntry/index.js.map +1 -1
- package/api/entities/MultiSigProposal/index.d.ts +0 -1
- package/api/entities/MultiSigProposal/index.d.ts.map +1 -1
- package/api/entities/NumberedPortfolio.d.ts +4 -0
- package/api/entities/NumberedPortfolio.d.ts.map +1 -1
- package/api/entities/NumberedPortfolio.js +1 -1
- package/api/entities/NumberedPortfolio.js.map +1 -1
- package/api/entities/Offering/index.d.ts +7 -4
- package/api/entities/Offering/index.d.ts.map +1 -1
- package/api/entities/Offering/index.js +6 -3
- package/api/entities/Offering/index.js.map +1 -1
- package/api/entities/Portfolio/index.d.ts +24 -0
- package/api/entities/Portfolio/index.d.ts.map +1 -1
- package/api/entities/Portfolio/index.js +110 -37
- package/api/entities/Portfolio/index.js.map +1 -1
- package/api/entities/Portfolio/types.d.ts +18 -0
- package/api/entities/Portfolio/types.d.ts.map +1 -1
- package/api/entities/Venue/index.d.ts +5 -5
- package/api/entities/Venue/index.d.ts.map +1 -1
- package/api/entities/Venue/index.js +4 -1
- package/api/entities/Venue/index.js.map +1 -1
- package/api/entities/common/namespaces/Authorizations.d.ts +18 -6
- package/api/entities/common/namespaces/Authorizations.d.ts.map +1 -1
- package/api/entities/common/namespaces/Authorizations.js +16 -4
- package/api/entities/common/namespaces/Authorizations.js.map +1 -1
- package/api/entities/types.d.ts +16 -2
- package/api/entities/types.d.ts.map +1 -1
- package/api/entities/types.js.map +1 -1
- package/api/procedures/acceptPrimaryKeyRotation.js +1 -1
- package/api/procedures/acceptPrimaryKeyRotation.js.map +1 -1
- package/api/procedures/addInstruction.d.ts.map +1 -1
- package/api/procedures/addInstruction.js +20 -1
- package/api/procedures/addInstruction.js.map +1 -1
- package/api/procedures/approveAllowance.d.ts.map +1 -1
- package/api/procedures/approveAllowance.js +17 -7
- package/api/procedures/approveAllowance.js.map +1 -1
- package/api/procedures/bondPolyx.d.ts +14 -2
- package/api/procedures/bondPolyx.d.ts.map +1 -1
- package/api/procedures/bondPolyx.js +39 -8
- package/api/procedures/bondPolyx.js.map +1 -1
- package/api/procedures/chillStaking.d.ts +36 -0
- package/api/procedures/chillStaking.d.ts.map +1 -0
- package/api/procedures/chillStaking.js +72 -0
- package/api/procedures/chillStaking.js.map +1 -0
- package/api/procedures/claimDividends.d.ts.map +1 -1
- package/api/procedures/claimDividends.js +11 -1
- package/api/procedures/claimDividends.js.map +1 -1
- package/api/procedures/configureDividendDistribution.d.ts.map +1 -1
- package/api/procedures/configureDividendDistribution.js +3 -2
- package/api/procedures/configureDividendDistribution.js.map +1 -1
- package/api/procedures/controllerTransfer.d.ts +7 -6
- package/api/procedures/controllerTransfer.d.ts.map +1 -1
- package/api/procedures/controllerTransfer.js +58 -35
- package/api/procedures/controllerTransfer.js.map +1 -1
- package/api/procedures/executeManualInstruction.d.ts +5 -1
- package/api/procedures/executeManualInstruction.d.ts.map +1 -1
- package/api/procedures/executeManualInstruction.js +5 -1
- package/api/procedures/executeManualInstruction.js.map +1 -1
- package/api/procedures/investInOffering.d.ts.map +1 -1
- package/api/procedures/investInOffering.js +41 -13
- package/api/procedures/investInOffering.js.map +1 -1
- package/api/procedures/launchOffering.d.ts.map +1 -1
- package/api/procedures/launchOffering.js +1 -0
- package/api/procedures/launchOffering.js.map +1 -1
- package/api/procedures/modifyAsset.js +1 -1
- package/api/procedures/modifyAsset.js.map +1 -1
- package/api/procedures/modifyFrozenTokens.d.ts +31 -0
- package/api/procedures/modifyFrozenTokens.d.ts.map +1 -0
- package/api/procedures/modifyFrozenTokens.js +123 -0
- package/api/procedures/modifyFrozenTokens.js.map +1 -0
- package/api/procedures/modifyInstructionAffirmation.d.ts +5 -1
- package/api/procedures/modifyInstructionAffirmation.d.ts.map +1 -1
- package/api/procedures/modifyInstructionAffirmation.js +10 -2
- package/api/procedures/modifyInstructionAffirmation.js.map +1 -1
- 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/nftControllerTransfer.d.ts +7 -6
- package/api/procedures/nftControllerTransfer.d.ts.map +1 -1
- package/api/procedures/nftControllerTransfer.js +42 -32
- package/api/procedures/nftControllerTransfer.js.map +1 -1
- package/api/procedures/nominateValidators.d.ts +6 -1
- package/api/procedures/nominateValidators.d.ts.map +1 -1
- package/api/procedures/nominateValidators.js +45 -6
- package/api/procedures/nominateValidators.js.map +1 -1
- package/api/procedures/redeemNft.js +1 -1
- package/api/procedures/redeemNft.js.map +1 -1
- package/api/procedures/redeemTokens.d.ts.map +1 -1
- package/api/procedures/redeemTokens.js +3 -1
- package/api/procedures/redeemTokens.js.map +1 -1
- package/api/procedures/removeAssetRequirement.js +1 -1
- package/api/procedures/removeAssetRequirement.js.map +1 -1
- package/api/procedures/removeCheckpointSchedule.js +1 -1
- package/api/procedures/removeCheckpointSchedule.js.map +1 -1
- package/api/procedures/removeCorporateAction.js +3 -3
- package/api/procedures/removeCorporateAction.js.map +1 -1
- package/api/procedures/setCustodian.d.ts +5 -1
- package/api/procedures/setCustodian.d.ts.map +1 -1
- package/api/procedures/setCustodian.js +2 -6
- package/api/procedures/setCustodian.js.map +1 -1
- package/api/procedures/setNftApproval.d.ts +29 -0
- package/api/procedures/setNftApproval.d.ts.map +1 -0
- package/api/procedures/setNftApproval.js +100 -0
- package/api/procedures/setNftApproval.js.map +1 -0
- package/api/procedures/setStakingController.d.ts +9 -1
- package/api/procedures/setStakingController.d.ts.map +1 -1
- package/api/procedures/setStakingController.js +10 -6
- package/api/procedures/setStakingController.js.map +1 -1
- package/api/procedures/setStakingPayee.d.ts +9 -1
- package/api/procedures/setStakingPayee.d.ts.map +1 -1
- package/api/procedures/setStakingPayee.js +10 -6
- package/api/procedures/setStakingPayee.js.map +1 -1
- package/api/procedures/toggleFreezeHolder.d.ts +23 -0
- package/api/procedures/toggleFreezeHolder.d.ts.map +1 -0
- package/api/procedures/toggleFreezeHolder.js +69 -0
- package/api/procedures/toggleFreezeHolder.js.map +1 -0
- package/api/procedures/toggleNftOperator.d.ts +26 -0
- package/api/procedures/toggleNftOperator.d.ts.map +1 -0
- package/api/procedures/toggleNftOperator.js +84 -0
- package/api/procedures/toggleNftOperator.js.map +1 -0
- package/api/procedures/transferFunds.d.ts.map +1 -1
- package/api/procedures/transferFunds.js +35 -4
- package/api/procedures/transferFunds.js.map +1 -1
- package/api/procedures/types.d.ts +73 -8
- package/api/procedures/types.d.ts.map +1 -1
- package/api/procedures/types.js.map +1 -1
- package/api/procedures/updateBondedPolyx.d.ts +13 -2
- package/api/procedures/updateBondedPolyx.d.ts.map +1 -1
- package/api/procedures/updateBondedPolyx.js +109 -46
- package/api/procedures/updateBondedPolyx.js.map +1 -1
- package/api/procedures/utils.d.ts +83 -2
- package/api/procedures/utils.d.ts.map +1 -1
- package/api/procedures/utils.js +171 -0
- package/api/procedures/utils.js.map +1 -1
- package/api/procedures/withdrawUnbondedPolyx.d.ts +11 -2
- package/api/procedures/withdrawUnbondedPolyx.d.ts.map +1 -1
- package/api/procedures/withdrawUnbondedPolyx.js +19 -15
- package/api/procedures/withdrawUnbondedPolyx.js.map +1 -1
- package/base/Context.d.ts +19 -11
- package/base/Context.d.ts.map +1 -1
- package/base/Context.js +22 -2
- package/base/Context.js.map +1 -1
- package/base/PolymeshTransactionBase.d.ts +8 -0
- package/base/PolymeshTransactionBase.d.ts.map +1 -1
- package/base/PolymeshTransactionBase.js +44 -39
- package/base/PolymeshTransactionBase.js.map +1 -1
- package/base/utils.d.ts +0 -1
- package/base/utils.d.ts.map +1 -1
- package/internal.d.ts +5 -0
- package/internal.d.ts.map +1 -1
- package/internal.js +14 -4
- package/internal.js.map +1 -1
- package/middleware/queries/assets.d.ts +13 -5
- package/middleware/queries/assets.d.ts.map +1 -1
- package/middleware/queries/assets.js +60 -27
- package/middleware/queries/assets.js.map +1 -1
- package/middleware/queries/authorizations.d.ts +2 -2
- package/middleware/queries/authorizations.d.ts.map +1 -1
- package/middleware/queries/authorizations.js +4 -3
- package/middleware/queries/authorizations.js.map +1 -1
- package/middleware/queries/claims.d.ts +4 -4
- package/middleware/queries/claims.d.ts.map +1 -1
- package/middleware/queries/claims.js +18 -6
- package/middleware/queries/claims.js.map +1 -1
- package/middleware/queries/common.d.ts +41 -1
- package/middleware/queries/common.d.ts.map +1 -1
- package/middleware/queries/common.js +51 -9
- package/middleware/queries/common.js.map +1 -1
- package/middleware/queries/distributions.d.ts +2 -2
- package/middleware/queries/distributions.d.ts.map +1 -1
- package/middleware/queries/distributions.js +10 -3
- package/middleware/queries/distributions.js.map +1 -1
- package/middleware/queries/events.d.ts +2 -2
- package/middleware/queries/events.d.ts.map +1 -1
- package/middleware/queries/events.js +4 -3
- package/middleware/queries/events.js.map +1 -1
- package/middleware/queries/externalAgents.d.ts +2 -2
- package/middleware/queries/externalAgents.d.ts.map +1 -1
- package/middleware/queries/externalAgents.js +4 -3
- package/middleware/queries/externalAgents.js.map +1 -1
- package/middleware/queries/extrinsics.d.ts +1 -1
- package/middleware/queries/extrinsics.d.ts.map +1 -1
- package/middleware/queries/extrinsics.js +14 -8
- package/middleware/queries/extrinsics.js.map +1 -1
- package/middleware/queries/multisigs.d.ts +2 -6
- package/middleware/queries/multisigs.d.ts.map +1 -1
- package/middleware/queries/multisigs.js +10 -4
- package/middleware/queries/multisigs.js.map +1 -1
- package/middleware/queries/polyxTransactions.d.ts +2 -1
- package/middleware/queries/polyxTransactions.d.ts.map +1 -1
- package/middleware/queries/polyxTransactions.js +5 -3
- package/middleware/queries/polyxTransactions.js.map +1 -1
- package/middleware/queries/settlements.d.ts +7 -7
- package/middleware/queries/settlements.d.ts.map +1 -1
- package/middleware/queries/settlements.js +23 -14
- package/middleware/queries/settlements.js.map +1 -1
- package/middleware/queries/stos.d.ts +2 -2
- package/middleware/queries/stos.d.ts.map +1 -1
- package/middleware/queries/stos.js +9 -5
- package/middleware/queries/stos.js.map +1 -1
- package/npm-package/polymeshassociation-polymesh-sdk-31.1.0-beta.20.tgz +0 -0
- package/package.json +6 -4
- package/types/txGroupConstants.d.ts +10 -2
- package/types/txGroupConstants.d.ts.map +1 -1
- package/types/txGroupConstants.js +16 -0
- package/types/txGroupConstants.js.map +1 -1
- package/utils/constants.d.ts +47 -0
- package/utils/constants.d.ts.map +1 -1
- package/utils/constants.js +48 -1
- package/utils/constants.js.map +1 -1
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +8 -2
- package/utils/conversion.js.map +1 -1
- package/utils/eth.d.ts +43 -0
- package/utils/eth.d.ts.map +1 -1
- package/utils/eth.js +76 -0
- package/utils/eth.js.map +1 -1
- package/utils/internal.d.ts +59 -5
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +159 -6
- package/utils/internal.js.map +1 -1
- package/npm-package/polymeshassociation-polymesh-sdk-31.1.0-beta.2.tgz +0 -0
|
@@ -17,15 +17,26 @@ export type Params = UpdatePolyxBondParams & ({
|
|
|
17
17
|
type: 'unbond';
|
|
18
18
|
} | {
|
|
19
19
|
type: 'bondExtra';
|
|
20
|
+
} | {
|
|
21
|
+
type: 'rebond';
|
|
20
22
|
});
|
|
21
23
|
/**
|
|
22
24
|
* @hidden
|
|
23
25
|
*/
|
|
24
|
-
export declare function prepareUnbondPolyx(this: Procedure<Params, void, Storage>, args: Params): Promise<TransactionSpec<void, ExtrinsicParams<'staking', 'unbond'>> | TransactionSpec<void, ExtrinsicParams<'staking', 'bondExtra'>>>;
|
|
26
|
+
export declare function prepareUnbondPolyx(this: Procedure<Params, void, Storage>, args: Params): Promise<TransactionSpec<void, ExtrinsicParams<'staking', 'unbond'>> | TransactionSpec<void, ExtrinsicParams<'staking', 'bondExtra'>> | TransactionSpec<void, ExtrinsicParams<'staking', 'rebond'>>>;
|
|
25
27
|
/**
|
|
26
28
|
* @hidden
|
|
29
|
+
*
|
|
30
|
+
* The staking pallet does not consult a signer's `ExtrinsicPermissions` — no Substrate pallet in
|
|
31
|
+
* the Polymesh runtime does — so no permission is required to run this, for a secondary key or
|
|
32
|
+
* an external agent alike.
|
|
33
|
+
*
|
|
34
|
+
* `true` rather than empty arrays: an empty `SimplePermissions` still routes through
|
|
35
|
+
* `Account.checkPermissions`, which reads the key's permissions from chain and **throws** for an
|
|
36
|
+
* Account with no Identity. That turns a check that should be a no-op into a failure, and costs
|
|
37
|
+
* a query either way.
|
|
27
38
|
*/
|
|
28
|
-
export declare function getAuthorization(this: Procedure<Params, void, Storage
|
|
39
|
+
export declare function getAuthorization(this: Procedure<Params, void, Storage>): ProcedureAuthorization;
|
|
29
40
|
/**
|
|
30
41
|
* @hidden
|
|
31
42
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateBondedPolyx.d.ts","sourceRoot":"","sources":["../../../src/api/procedures/updateBondedPolyx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateBondedPolyx.d.ts","sourceRoot":"","sources":["../../../src/api/procedures/updateBondedPolyx.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,SAAS,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAa,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG5F;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,qBAAqB,GACxC,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAqHpE;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,EACtC,IAAI,EAAE,MAAM,GACX,OAAO,CACN,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,GAC3D,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,GAC9D,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAC9D,CAmCA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAI/F;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAiB7F;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAO,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CACC,CAAC"}
|
|
@@ -8,62 +8,122 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.updateBondedPolyx = void 0;
|
|
13
16
|
exports.prepareUnbondPolyx = prepareUnbondPolyx;
|
|
14
17
|
exports.getAuthorization = getAuthorization;
|
|
15
18
|
exports.prepareStorage = prepareStorage;
|
|
19
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
16
20
|
const internal_1 = require("../../internal");
|
|
17
21
|
const types_1 = require("../../types");
|
|
18
22
|
const conversion_1 = require("../../utils/conversion");
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*
|
|
26
|
+
* @throws if the acting account controls no bond
|
|
27
|
+
*/
|
|
28
|
+
function assertControllerEntry(controllerEntry, actingAccount) {
|
|
29
|
+
if (!controllerEntry) {
|
|
30
|
+
throw new internal_1.PolymeshError({
|
|
31
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
32
|
+
message: 'The caller must be a controller account',
|
|
33
|
+
data: { actingAccount: actingAccount.address },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return controllerEntry;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @hidden
|
|
40
|
+
*
|
|
41
|
+
* @throws if `amount` cannot be rebonded
|
|
42
|
+
*/
|
|
43
|
+
function assertRebondable(amount, controllerEntry, actingAccount) {
|
|
44
|
+
const { unlocking } = assertControllerEntry(controllerEntry, actingAccount);
|
|
45
|
+
/* the chain refuses a rebond with nothing unbonding, whatever the amount */
|
|
46
|
+
if (!unlocking.length) {
|
|
47
|
+
throw new internal_1.PolymeshError({
|
|
48
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
49
|
+
message: 'There is no unbonding POLYX to rebond',
|
|
50
|
+
data: { actingAccount: actingAccount.address },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const unlockingTotal = unlocking.reduce((total, { value }) => total.plus(value), new bignumber_js_1.default(0));
|
|
54
|
+
if (unlockingTotal.lt(amount)) {
|
|
55
|
+
throw new internal_1.PolymeshError({
|
|
56
|
+
code: types_1.ErrorCode.InsufficientBalance,
|
|
57
|
+
message: 'Insufficient unbonding POLYX',
|
|
58
|
+
data: {
|
|
59
|
+
amount: amount.toString(),
|
|
60
|
+
unlocking: unlockingTotal.toString(),
|
|
61
|
+
actingAccount: actingAccount.address,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @hidden
|
|
68
|
+
*
|
|
69
|
+
* @throws if `amount` cannot be unbonded
|
|
70
|
+
*/
|
|
71
|
+
function assertUnbondable(amount, controllerEntry, actingAccount) {
|
|
72
|
+
const { active } = assertControllerEntry(controllerEntry, actingAccount);
|
|
73
|
+
if (active.lt(amount)) {
|
|
74
|
+
throw new internal_1.PolymeshError({
|
|
75
|
+
code: types_1.ErrorCode.InsufficientBalance,
|
|
76
|
+
message: 'Insufficient bonded POLYX',
|
|
77
|
+
data: {
|
|
78
|
+
amount: amount.toString(),
|
|
79
|
+
active: active.toString(),
|
|
80
|
+
actingAccount: actingAccount.address,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @hidden
|
|
87
|
+
*
|
|
88
|
+
* @throws if `amount` cannot be added to an existing bond
|
|
89
|
+
*/
|
|
90
|
+
function assertBondExtraPossible(amount, actingBalance, isStash, actingAccount) {
|
|
91
|
+
if (!isStash) {
|
|
92
|
+
throw new internal_1.PolymeshError({
|
|
93
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
94
|
+
message: 'The caller must be a stash account',
|
|
95
|
+
data: { actingAccount: actingAccount.address },
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (actingBalance.free.lt(amount)) {
|
|
99
|
+
throw new internal_1.PolymeshError({
|
|
100
|
+
code: types_1.ErrorCode.InsufficientBalance,
|
|
101
|
+
message: 'The stash account has insufficient free balance',
|
|
102
|
+
data: {
|
|
103
|
+
actingAccount: actingAccount.address,
|
|
104
|
+
free: actingBalance.free.toString(),
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
19
109
|
/**
|
|
20
110
|
* @hidden
|
|
21
111
|
*/
|
|
22
112
|
function prepareUnbondPolyx(args) {
|
|
23
|
-
const { context: { polymeshApi: { tx: { staking: { bondExtra, unbond }, }, }, }, context, storage: { actingAccount, actingBalance, controllerEntry, isStash }, } = this;
|
|
113
|
+
const { context: { polymeshApi: { tx: { staking: { bondExtra, rebond, unbond }, }, }, }, context, storage: { actingAccount, actingBalance, controllerEntry, isStash }, } = this;
|
|
24
114
|
const { amount, type } = args;
|
|
25
115
|
let transaction;
|
|
26
|
-
if (type === '
|
|
116
|
+
if (type === 'rebond') {
|
|
117
|
+
transaction = rebond;
|
|
118
|
+
assertRebondable(amount, controllerEntry, actingAccount);
|
|
119
|
+
}
|
|
120
|
+
else if (type === 'unbond') {
|
|
27
121
|
transaction = unbond;
|
|
28
|
-
|
|
29
|
-
throw new internal_1.PolymeshError({
|
|
30
|
-
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
31
|
-
message: 'The caller must be a controller account',
|
|
32
|
-
data: { actingAccount: actingAccount.address },
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
const { active } = controllerEntry;
|
|
36
|
-
if (active.lt(amount)) {
|
|
37
|
-
throw new internal_1.PolymeshError({
|
|
38
|
-
code: types_1.ErrorCode.InsufficientBalance,
|
|
39
|
-
message: 'Insufficient bonded POLYX',
|
|
40
|
-
data: {
|
|
41
|
-
amount: amount.toString(),
|
|
42
|
-
active: active.toString(),
|
|
43
|
-
actingAccount: actingAccount.address,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}
|
|
122
|
+
assertUnbondable(amount, controllerEntry, actingAccount);
|
|
47
123
|
}
|
|
48
124
|
else {
|
|
49
125
|
transaction = bondExtra;
|
|
50
|
-
|
|
51
|
-
throw new internal_1.PolymeshError({
|
|
52
|
-
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
53
|
-
message: 'The caller must be a stash account',
|
|
54
|
-
data: { actingAccount: actingAccount.address },
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
if (actingBalance.free.lt(amount)) {
|
|
58
|
-
throw new internal_1.PolymeshError({
|
|
59
|
-
code: types_1.ErrorCode.InsufficientBalance,
|
|
60
|
-
message: 'The stash account has insufficient free balance',
|
|
61
|
-
data: {
|
|
62
|
-
actingAccount: actingAccount.address,
|
|
63
|
-
free: actingBalance.free.toString(),
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
}
|
|
126
|
+
assertBondExtraPossible(amount, actingBalance, isStash, actingAccount);
|
|
67
127
|
}
|
|
68
128
|
const rawAmount = (0, conversion_1.bigNumberToBalance)(amount, context);
|
|
69
129
|
return Promise.resolve({
|
|
@@ -74,16 +134,19 @@ function prepareUnbondPolyx(args) {
|
|
|
74
134
|
}
|
|
75
135
|
/**
|
|
76
136
|
* @hidden
|
|
137
|
+
*
|
|
138
|
+
* The staking pallet does not consult a signer's `ExtrinsicPermissions` — no Substrate pallet in
|
|
139
|
+
* the Polymesh runtime does — so no permission is required to run this, for a secondary key or
|
|
140
|
+
* an external agent alike.
|
|
141
|
+
*
|
|
142
|
+
* `true` rather than empty arrays: an empty `SimplePermissions` still routes through
|
|
143
|
+
* `Account.checkPermissions`, which reads the key's permissions from chain and **throws** for an
|
|
144
|
+
* Account with no Identity. That turns a check that should be a no-op into a failure, and costs
|
|
145
|
+
* a query either way.
|
|
77
146
|
*/
|
|
78
|
-
function getAuthorization(
|
|
79
|
-
const { type } = args;
|
|
80
|
-
const txTag = type === 'unbond' ? types_1.TxTags.staking.Unbond : types_1.TxTags.staking.BondExtra;
|
|
147
|
+
function getAuthorization() {
|
|
81
148
|
return {
|
|
82
|
-
permissions:
|
|
83
|
-
assets: [],
|
|
84
|
-
transactions: [txTag],
|
|
85
|
-
portfolios: [],
|
|
86
|
-
},
|
|
149
|
+
permissions: true,
|
|
87
150
|
};
|
|
88
151
|
}
|
|
89
152
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateBondedPolyx.js","sourceRoot":"","sources":["../../../src/api/procedures/updateBondedPolyx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateBondedPolyx.js","sourceRoot":"","sources":["../../../src/api/procedures/updateBondedPolyx.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6IA,gDA0CC;AAcD,4CAIC;AAKD,wCAiBC;AA/ND,gEAAqC;AAErC,yCAAsD;AACtD,mCAA4F;AAE5F,mDAAwD;AAkBxD;;;;GAIG;AACH,SAAS,qBAAqB,CAC5B,eAAqC,EACrC,aAAsB;IAEtB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,wBAAa,CAAC;YACtB,IAAI,EAAE,iBAAS,CAAC,iBAAiB;YACjC,OAAO,EAAE,yCAAyC;YAClD,IAAI,EAAE,EAAE,aAAa,EAAE,aAAa,CAAC,OAAO,EAAE;SAC/C,CAAC,CAAC;IACL,CAAC;IAED,OA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CAAC;CAAA;AAED;;GAEG;AACI,MAAM,iBAAiB,GAAG,GAAqC,EAAE,CACtE,IAAI,oBAAS,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;AADzD,QAAA,iBAAiB,qBACwC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ISubmittableResult } from '@polkadot/types/types';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { Account, AuthorizationRequest, BaseAsset, Checkpoint, CheckpointSchedule, Context, CustomPermissionGroup, Identity, Instruction, KnownPermissionGroup } from '../../internal';
|
|
4
|
-
import { AssetHolderId, AssetHolderLike, Authorization, Condition, GenericAuthorizationData, InputCondition, InputTaxWithholding, InstructionDetails, PermissionedAccount, PortfolioId, Signer, TransactionPermissions, TxTag } from '../../types';
|
|
3
|
+
import { Account, AuthorizationRequest, BaseAsset, Checkpoint, CheckpointSchedule, Context, CustomPermissionGroup, DefaultPortfolio, Identity, Instruction, KnownPermissionGroup, NumberedPortfolio } from '../../internal';
|
|
4
|
+
import { AssetHolderId, AssetHolderLike, Authorization, Condition, GenericAuthorizationData, InputCondition, InputTaxWithholding, InstructionDetails, PermissionedAccount, PortfolioId, PortfolioLike, Signer, TransactionPermissions, TxTag } from '../../types';
|
|
5
5
|
/**
|
|
6
6
|
* @hidden
|
|
7
7
|
*/
|
|
@@ -18,6 +18,19 @@ export declare function assertInstructionValidForLocking(details: InstructionDet
|
|
|
18
18
|
* @hidden
|
|
19
19
|
*/
|
|
20
20
|
export declare function assertInstructionValidForUnlocking(details: InstructionDetails): void;
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*
|
|
24
|
+
* Throw if the connected chain has no extrinsic for `tag`. For a procedure whose extrinsic was
|
|
25
|
+
* added in a later runtime than the oldest the SDK supports, so that an older chain refuses it
|
|
26
|
+
* with a clear error rather than failing to find the extrinsic
|
|
27
|
+
*
|
|
28
|
+
* @param sinceVersion - the first Polymesh release with the extrinsic, reported in the error
|
|
29
|
+
*
|
|
30
|
+
* @note this reads the chain's metadata, not its spec version, so it is also right for a runtime
|
|
31
|
+
* that is not on the public release line
|
|
32
|
+
*/
|
|
33
|
+
export declare function assertTxSupported(tag: TxTag, sinceVersion: string, context: Context): void;
|
|
21
34
|
/**
|
|
22
35
|
* @hidden
|
|
23
36
|
*/
|
|
@@ -127,8 +140,76 @@ export declare function addManualFees(currentFee: BigNumber | undefined, tags: T
|
|
|
127
140
|
* @hidden
|
|
128
141
|
*/
|
|
129
142
|
export declare function assertBallotRecordDateValid(checkpoint: CheckpointSchedule | Date, startDate: Date): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* @hidden
|
|
145
|
+
*
|
|
146
|
+
* The storage a controller transfer keeps about where it delivers, shared by the fungible and NFT
|
|
147
|
+
* procedures
|
|
148
|
+
*/
|
|
149
|
+
export interface ControllerTransferDestination {
|
|
150
|
+
did: string;
|
|
151
|
+
actingAddress: string;
|
|
152
|
+
destinationAssetHolder: Account | DefaultPortfolio | NumberedPortfolio;
|
|
153
|
+
/**
|
|
154
|
+
* whether the destination is somewhere `controllerTransfer` can deliver to, i.e. the acting
|
|
155
|
+
* Account itself or a Portfolio of the signing Identity. Anywhere else takes
|
|
156
|
+
* `controllerTransferTo`, available from Polymesh 8.1.1
|
|
157
|
+
*/
|
|
158
|
+
isDestinationCallers: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @hidden
|
|
162
|
+
*
|
|
163
|
+
* Resolve where a controller transfer delivers, defaulting to the signing Identity's default
|
|
164
|
+
* Portfolio, and decide which of the chain's two extrinsics can reach it
|
|
165
|
+
*/
|
|
166
|
+
export declare function getControllerTransferDestination(destination: AssetHolderLike | undefined, context: Context): Promise<ControllerTransferDestination>;
|
|
167
|
+
/**
|
|
168
|
+
* @hidden
|
|
169
|
+
*
|
|
170
|
+
* Read where a controller transfer takes from, given as `origin` or as the deprecated
|
|
171
|
+
* `originPortfolio`. The two mean the same thing, so passing both says nothing about which was
|
|
172
|
+
* meant
|
|
173
|
+
*/
|
|
174
|
+
export declare function getControllerTransferOrigin(args: {
|
|
175
|
+
origin?: AssetHolderLike;
|
|
176
|
+
originPortfolio?: PortfolioLike;
|
|
177
|
+
}): AssetHolderLike;
|
|
178
|
+
/**
|
|
179
|
+
* @hidden
|
|
180
|
+
*
|
|
181
|
+
* Mirror the chain's receiver affirmation check on a controller transfer to a named destination
|
|
182
|
+
* (`controller_transfer_to`). A forced transfer cannot affirm on the receiver's behalf, so a
|
|
183
|
+
* destination that would have to affirm the incoming transfer is accepted only if the caller
|
|
184
|
+
* controls it: the caller's own Account, or a Portfolio in the caller's custody
|
|
185
|
+
*
|
|
186
|
+
* A destination has to affirm when the Identity governing it (a Portfolio's custodian, else the
|
|
187
|
+
* Account's or Portfolio's owner) has opted in to mandatory receiver affirmation, unless the
|
|
188
|
+
* Asset is exempt from affirmation or has been pre-approved by that Identity or, for a Portfolio,
|
|
189
|
+
* by the Portfolio itself
|
|
190
|
+
*
|
|
191
|
+
* @param caller.did - Identity the extrinsic is dispatched for
|
|
192
|
+
* @param caller.address - Account the extrinsic is dispatched from
|
|
193
|
+
*/
|
|
194
|
+
export declare function assertControllerTransferDestinationAccepted(destination: Account | NumberedPortfolio | DefaultPortfolio, asset: BaseAsset, caller: {
|
|
195
|
+
did: string;
|
|
196
|
+
address: string;
|
|
197
|
+
}, context: Context): Promise<void>;
|
|
130
198
|
/**
|
|
131
199
|
* @hidden
|
|
132
200
|
*/
|
|
133
201
|
export declare function getAssetHolderDid(assetHolderLike: AssetHolderLike, context: Context): Promise<string | undefined>;
|
|
202
|
+
/**
|
|
203
|
+
* @hidden
|
|
204
|
+
*
|
|
205
|
+
* Throw if any holder is frozen outright for the Asset it would send. The chain refuses to move an
|
|
206
|
+
* Asset out of a frozen holder by any route but a controller transfer
|
|
207
|
+
*
|
|
208
|
+
* @note the frozen part of a balance is already netted out of `free`, so this checks only a freeze
|
|
209
|
+
* on the holder itself
|
|
210
|
+
*/
|
|
211
|
+
export declare function assertHoldersNotFrozen(holdings: {
|
|
212
|
+
holder: AssetHolderLike;
|
|
213
|
+
asset: string | BaseAsset;
|
|
214
|
+
}[], context: Context): Promise<void>;
|
|
134
215
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/api/procedures/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,qBAAqB,EACrB,QAAQ,EACR,WAAW,EACX,oBAAoB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/api/procedures/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EAIlB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,aAAa,EACb,eAAe,EACf,aAAa,EAEb,SAAS,EAIT,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAGlB,mBAAmB,EAEnB,WAAW,EACX,aAAa,EACb,MAAM,EAEN,sBAAsB,EACtB,KAAK,EACN,MAAM,SAAS,CAAC;AAkBjB;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAiBD;;GAEG;AACH,wBAAsB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EAAE,aAAa,CAAC;CACjC,GAAG,eAAe,CAoBlB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,2CAA2C,CAC/D,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,gBAAgB,EAC3D,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EACxC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAgDf;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAAE,EAClE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
package/api/procedures/utils.js
CHANGED
|
@@ -17,6 +17,7 @@ exports.assertInstructionValid = assertInstructionValid;
|
|
|
17
17
|
exports.assertInstructionValidForManualExecution = assertInstructionValidForManualExecution;
|
|
18
18
|
exports.assertInstructionValidForLocking = assertInstructionValidForLocking;
|
|
19
19
|
exports.assertInstructionValidForUnlocking = assertInstructionValidForUnlocking;
|
|
20
|
+
exports.assertTxSupported = assertTxSupported;
|
|
20
21
|
exports.assertPortfolioExists = assertPortfolioExists;
|
|
21
22
|
exports.assertAssetHolderExists = assertAssetHolderExists;
|
|
22
23
|
exports.assertVenueExists = assertVenueExists;
|
|
@@ -36,7 +37,11 @@ exports.getGroupFromPermissions = getGroupFromPermissions;
|
|
|
36
37
|
exports.assertGroupDoesNotExist = assertGroupDoesNotExist;
|
|
37
38
|
exports.addManualFees = addManualFees;
|
|
38
39
|
exports.assertBallotRecordDateValid = assertBallotRecordDateValid;
|
|
40
|
+
exports.getControllerTransferDestination = getControllerTransferDestination;
|
|
41
|
+
exports.getControllerTransferOrigin = getControllerTransferOrigin;
|
|
42
|
+
exports.assertControllerTransferDestinationAccepted = assertControllerTransferDestinationAccepted;
|
|
39
43
|
exports.getAssetHolderDid = getAssetHolderDid;
|
|
44
|
+
exports.assertHoldersNotFrozen = assertHoldersNotFrozen;
|
|
40
45
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
41
46
|
const lodash_1 = require("lodash");
|
|
42
47
|
const internal_1 = require("../../internal");
|
|
@@ -144,6 +149,30 @@ function assertInstructionValidForUnlocking(details) {
|
|
|
144
149
|
});
|
|
145
150
|
}
|
|
146
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* @hidden
|
|
154
|
+
*
|
|
155
|
+
* Throw if the connected chain has no extrinsic for `tag`. For a procedure whose extrinsic was
|
|
156
|
+
* added in a later runtime than the oldest the SDK supports, so that an older chain refuses it
|
|
157
|
+
* with a clear error rather than failing to find the extrinsic
|
|
158
|
+
*
|
|
159
|
+
* @param sinceVersion - the first Polymesh release with the extrinsic, reported in the error
|
|
160
|
+
*
|
|
161
|
+
* @note this reads the chain's metadata, not its spec version, so it is also right for a runtime
|
|
162
|
+
* that is not on the public release line
|
|
163
|
+
*/
|
|
164
|
+
function assertTxSupported(tag, sinceVersion, context) {
|
|
165
|
+
var _a;
|
|
166
|
+
const [section, method] = tag.split('.');
|
|
167
|
+
const { tx } = context.polymeshApi;
|
|
168
|
+
if (!((_a = tx[section]) === null || _a === void 0 ? void 0 : _a[method])) {
|
|
169
|
+
throw new internal_1.PolymeshError({
|
|
170
|
+
code: types_1.ErrorCode.NotSupported,
|
|
171
|
+
message: `The connected chain does not support "${tag}", which requires Polymesh ${sinceVersion} or later`,
|
|
172
|
+
data: { tag, specVersion: context.specVersion },
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
147
176
|
/**
|
|
148
177
|
* @hidden
|
|
149
178
|
*/
|
|
@@ -644,6 +673,120 @@ function assertBallotRecordDateValid(checkpoint, startDate) {
|
|
|
644
673
|
}
|
|
645
674
|
});
|
|
646
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* @hidden
|
|
678
|
+
*
|
|
679
|
+
* Resolve where a controller transfer delivers, defaulting to the signing Identity's default
|
|
680
|
+
* Portfolio, and decide which of the chain's two extrinsics can reach it
|
|
681
|
+
*/
|
|
682
|
+
function getControllerTransferDestination(destination, context) {
|
|
683
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
684
|
+
const [{ did }, { address: actingAddress }] = yield Promise.all([
|
|
685
|
+
context.getSigningIdentity(),
|
|
686
|
+
context.getActingAccount(),
|
|
687
|
+
]);
|
|
688
|
+
const destinationAssetHolder = destination
|
|
689
|
+
? (0, conversion_1.assetHolderLikeToAssetHolder)(destination, context)
|
|
690
|
+
: new internal_1.DefaultPortfolio({ did }, context);
|
|
691
|
+
/*
|
|
692
|
+
* `controller_transfer` names only the kind of destination, and resolves an Account kind to the
|
|
693
|
+
* caller's own Account. So an Account destination is the caller's only if it is the acting
|
|
694
|
+
* Account, even when another Account of the same Identity is named
|
|
695
|
+
*/
|
|
696
|
+
const isDestinationCallers = destinationAssetHolder instanceof internal_1.Account
|
|
697
|
+
? destinationAssetHolder.address === actingAddress
|
|
698
|
+
: destinationAssetHolder.owner.did === did;
|
|
699
|
+
return {
|
|
700
|
+
did,
|
|
701
|
+
actingAddress,
|
|
702
|
+
destinationAssetHolder,
|
|
703
|
+
isDestinationCallers,
|
|
704
|
+
};
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* @hidden
|
|
709
|
+
*
|
|
710
|
+
* Read where a controller transfer takes from, given as `origin` or as the deprecated
|
|
711
|
+
* `originPortfolio`. The two mean the same thing, so passing both says nothing about which was
|
|
712
|
+
* meant
|
|
713
|
+
*/
|
|
714
|
+
function getControllerTransferOrigin(args) {
|
|
715
|
+
const { origin, originPortfolio } = args;
|
|
716
|
+
if (origin !== undefined && originPortfolio !== undefined) {
|
|
717
|
+
throw new internal_1.PolymeshError({
|
|
718
|
+
code: types_1.ErrorCode.ValidationError,
|
|
719
|
+
message: 'Pass "origin" or the deprecated "originPortfolio", not both',
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
const holder = origin !== null && origin !== void 0 ? origin : originPortfolio;
|
|
723
|
+
if (holder === undefined) {
|
|
724
|
+
throw new internal_1.PolymeshError({
|
|
725
|
+
code: types_1.ErrorCode.ValidationError,
|
|
726
|
+
message: 'Pass "origin", the Portfolio or Account to transfer from',
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
return holder;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* @hidden
|
|
733
|
+
*
|
|
734
|
+
* Mirror the chain's receiver affirmation check on a controller transfer to a named destination
|
|
735
|
+
* (`controller_transfer_to`). A forced transfer cannot affirm on the receiver's behalf, so a
|
|
736
|
+
* destination that would have to affirm the incoming transfer is accepted only if the caller
|
|
737
|
+
* controls it: the caller's own Account, or a Portfolio in the caller's custody
|
|
738
|
+
*
|
|
739
|
+
* A destination has to affirm when the Identity governing it (a Portfolio's custodian, else the
|
|
740
|
+
* Account's or Portfolio's owner) has opted in to mandatory receiver affirmation, unless the
|
|
741
|
+
* Asset is exempt from affirmation or has been pre-approved by that Identity or, for a Portfolio,
|
|
742
|
+
* by the Portfolio itself
|
|
743
|
+
*
|
|
744
|
+
* @param caller.did - Identity the extrinsic is dispatched for
|
|
745
|
+
* @param caller.address - Account the extrinsic is dispatched from
|
|
746
|
+
*/
|
|
747
|
+
function assertControllerTransferDestinationAccepted(destination, asset, caller, context) {
|
|
748
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
749
|
+
let governingIdentity;
|
|
750
|
+
let isControlledByCaller;
|
|
751
|
+
let isPortfolioPreApproved = false;
|
|
752
|
+
if (destination instanceof internal_1.Account) {
|
|
753
|
+
governingIdentity = yield destination.getIdentity();
|
|
754
|
+
isControlledByCaller = destination.address === caller.address;
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
[governingIdentity, isPortfolioPreApproved] = yield Promise.all([
|
|
758
|
+
destination.getCustodian(),
|
|
759
|
+
destination.isAssetPreApproved(asset),
|
|
760
|
+
]);
|
|
761
|
+
isControlledByCaller = governingIdentity.did === caller.did;
|
|
762
|
+
}
|
|
763
|
+
if (isControlledByCaller) {
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
if (!governingIdentity) {
|
|
767
|
+
throw new internal_1.PolymeshError({
|
|
768
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
769
|
+
message: 'The destination Account has no Identity to receive the Asset',
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
const rawAssetId = (0, conversion_1.assetToMeshAssetId)(asset, context);
|
|
773
|
+
const [requiresAffirmation, rawIsExempt, isIdentityPreApproved] = yield Promise.all([
|
|
774
|
+
governingIdentity.isMandatoryReceiverAffirmationEnabled(),
|
|
775
|
+
context.polymeshApi.query.asset.assetsExemptFromAffirmation(rawAssetId),
|
|
776
|
+
governingIdentity.isAssetPreApproved(asset),
|
|
777
|
+
]);
|
|
778
|
+
if (requiresAffirmation &&
|
|
779
|
+
!(0, conversion_1.boolToBoolean)(rawIsExempt) &&
|
|
780
|
+
!isIdentityPreApproved &&
|
|
781
|
+
!isPortfolioPreApproved) {
|
|
782
|
+
throw new internal_1.PolymeshError({
|
|
783
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
784
|
+
message: 'The destination must affirm incoming transfers of this Asset, which a controller transfer cannot do. It must pre-approve the Asset first',
|
|
785
|
+
data: { receiverIdentity: governingIdentity.did },
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
}
|
|
647
790
|
/**
|
|
648
791
|
* @hidden
|
|
649
792
|
*/
|
|
@@ -660,4 +803,32 @@ function getAssetHolderDid(assetHolderLike, context) {
|
|
|
660
803
|
}
|
|
661
804
|
});
|
|
662
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* @hidden
|
|
808
|
+
*
|
|
809
|
+
* Throw if any holder is frozen outright for the Asset it would send. The chain refuses to move an
|
|
810
|
+
* Asset out of a frozen holder by any route but a controller transfer
|
|
811
|
+
*
|
|
812
|
+
* @note the frozen part of a balance is already netted out of `free`, so this checks only a freeze
|
|
813
|
+
* on the holder itself
|
|
814
|
+
*/
|
|
815
|
+
function assertHoldersNotFrozen(holdings, context) {
|
|
816
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
817
|
+
const statuses = yield Promise.all(holdings.map((_a) => __awaiter(this, [_a], void 0, function* ({ holder, asset }) {
|
|
818
|
+
const baseAsset = yield (0, internal_2.asBaseAsset)(asset, context);
|
|
819
|
+
const { isFrozen } = yield (0, internal_2.getHolderFreezeStatus)(holder, baseAsset, context);
|
|
820
|
+
return { holder, assetId: baseAsset.id, isFrozen };
|
|
821
|
+
})));
|
|
822
|
+
const frozenHolders = statuses
|
|
823
|
+
.filter(({ isFrozen }) => isFrozen)
|
|
824
|
+
.map(({ holder, assetId }) => ({ holder, assetId }));
|
|
825
|
+
if (frozenHolders.length) {
|
|
826
|
+
throw new internal_1.PolymeshError({
|
|
827
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
828
|
+
message: 'A sender is frozen for the Asset it would send',
|
|
829
|
+
data: { frozenHolders },
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
}
|
|
663
834
|
//# sourceMappingURL=utils.js.map
|