@airgap/substrate 0.13.45-beta.2 → 0.13.45-beta.3
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/package.json +5 -5
- package/v0/index.js +12 -12
- package/v0/index.js.map +1 -1
- package/v0/protocol/SubstrateCryptoClient.js +23 -94
- package/v0/protocol/SubstrateCryptoClient.js.map +1 -1
- package/v0/protocol/SubstrateDelegateProtocol.js +297 -542
- package/v0/protocol/SubstrateDelegateProtocol.js.map +1 -1
- package/v0/protocol/SubstrateNetwork.js +1 -1
- package/v0/protocol/SubstrateNetwork.js.map +1 -1
- package/v0/protocol/SubstrateProtocol.js +333 -672
- package/v0/protocol/SubstrateProtocol.js.map +1 -1
- package/v0/protocol/SubstrateProtocolOptions.js +25 -93
- package/v0/protocol/SubstrateProtocolOptions.js.map +1 -1
- package/v0/protocol/astar/AstarAddress.js +7 -27
- package/v0/protocol/astar/AstarAddress.js.map +1 -1
- package/v0/protocol/common/SubstrateAccountController.js +400 -687
- package/v0/protocol/common/SubstrateAccountController.js.map +1 -1
- package/v0/protocol/common/SubstrateTransactionController.d.ts +0 -1
- package/v0/protocol/common/SubstrateTransactionController.js +185 -346
- package/v0/protocol/common/SubstrateTransactionController.js.map +1 -1
- package/v0/protocol/common/blockexplorer/SubstrateBlockExplorerClient.js +52 -100
- package/v0/protocol/common/blockexplorer/SubstrateBlockExplorerClient.js.map +1 -1
- package/v0/protocol/common/data/account/SubstrateAccountInfo.js +27 -29
- package/v0/protocol/common/data/account/SubstrateAccountInfo.js.map +1 -1
- package/v0/protocol/common/data/account/SubstrateAddress.d.ts +0 -1
- package/v0/protocol/common/data/account/SubstrateAddress.js +43 -46
- package/v0/protocol/common/data/account/SubstrateAddress.js.map +1 -1
- package/v0/protocol/common/data/account/SubstrateRegistration.js +50 -56
- package/v0/protocol/common/data/account/SubstrateRegistration.js.map +1 -1
- package/v0/protocol/common/data/metadata/Metadata.js +24 -25
- package/v0/protocol/common/data/metadata/Metadata.js.map +1 -1
- package/v0/protocol/common/data/metadata/MetadataVersioned.js +2 -5
- package/v0/protocol/common/data/metadata/MetadataVersioned.js.map +1 -1
- package/v0/protocol/common/data/metadata/decorator/MetadataDecorator.js +18 -20
- package/v0/protocol/common/data/metadata/decorator/MetadataDecorator.js.map +1 -1
- package/v0/protocol/common/data/metadata/decorator/constant/SubstrateConstant.d.ts +0 -1
- package/v0/protocol/common/data/metadata/decorator/storage/SubstrateStorageEntry.js +89 -237
- package/v0/protocol/common/data/metadata/decorator/storage/SubstrateStorageEntry.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/MetadataV11.js +43 -63
- package/v0/protocol/common/data/metadata/v11/MetadataV11.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Call.js +30 -51
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Call.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Constant.js +20 -38
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Constant.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Error.js +16 -34
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Error.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Event.js +18 -36
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Event.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Module.js +29 -51
- package/v0/protocol/common/data/metadata/v11/module/MetadataV11Module.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/module/storage/MetadataV11Storage.js +17 -35
- package/v0/protocol/common/data/metadata/v11/module/storage/MetadataV11Storage.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/module/storage/MetadataV11StorageEntry.js +23 -41
- package/v0/protocol/common/data/metadata/v11/module/storage/MetadataV11StorageEntry.js.map +1 -1
- package/v0/protocol/common/data/metadata/v11/module/storage/MetadataV11StorageEntryType.js +72 -114
- package/v0/protocol/common/data/metadata/v11/module/storage/MetadataV11StorageEntryType.js.map +1 -1
- package/v0/protocol/common/data/metadata/v12/MetadataV12.js +41 -61
- package/v0/protocol/common/data/metadata/v12/MetadataV12.js.map +1 -1
- package/v0/protocol/common/data/metadata/v12/module/MetadataV12Module.js +14 -32
- package/v0/protocol/common/data/metadata/v12/module/MetadataV12Module.js.map +1 -1
- package/v0/protocol/common/data/metadata/v13/MetadataV13.js +41 -61
- package/v0/protocol/common/data/metadata/v13/MetadataV13.js.map +1 -1
- package/v0/protocol/common/data/metadata/v13/module/MetadataV13Module.js +31 -53
- package/v0/protocol/common/data/metadata/v13/module/MetadataV13Module.js.map +1 -1
- package/v0/protocol/common/data/metadata/v13/module/storage/MetadataV13Storage.js +17 -35
- package/v0/protocol/common/data/metadata/v13/module/storage/MetadataV13Storage.js.map +1 -1
- package/v0/protocol/common/data/metadata/v13/module/storage/MetadataV13StorageEntry.js +23 -41
- package/v0/protocol/common/data/metadata/v13/module/storage/MetadataV13StorageEntry.js.map +1 -1
- package/v0/protocol/common/data/metadata/v13/module/storage/MetadataV13StorageEntryType.js +83 -130
- package/v0/protocol/common/data/metadata/v13/module/storage/MetadataV13StorageEntryType.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/MetadataV14.js +53 -74
- package/v0/protocol/common/data/metadata/v14/MetadataV14.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/MetadataV14Component.js +7 -25
- package/v0/protocol/common/data/metadata/v14/MetadataV14Component.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/extrinsic/MetadataV14Extrinsic.js +17 -35
- package/v0/protocol/common/data/metadata/v14/extrinsic/MetadataV14Extrinsic.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/extrinsic/MetadataV14SignedExtension.js +16 -34
- package/v0/protocol/common/data/metadata/v14/extrinsic/MetadataV14SignedExtension.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Call.js +8 -28
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Call.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Constant.js +19 -37
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Constant.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Error.js +8 -28
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Error.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Event.js +8 -28
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Event.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Pallet.js +30 -48
- package/v0/protocol/common/data/metadata/v14/pallet/MetadataV14Pallet.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/pallet/storage/MetadataV14Storage.js +16 -34
- package/v0/protocol/common/data/metadata/v14/pallet/storage/MetadataV14Storage.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/pallet/storage/MetadataV14StorageEntry.js +23 -41
- package/v0/protocol/common/data/metadata/v14/pallet/storage/MetadataV14StorageEntry.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/pallet/storage/MetadataV14StorageEntryType.js +49 -90
- package/v0/protocol/common/data/metadata/v14/pallet/storage/MetadataV14StorageEntryType.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/registry/MetadataV14PortableRegistry.js +20 -41
- package/v0/protocol/common/data/metadata/v14/registry/MetadataV14PortableRegistry.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/registry/MetadataV14PortableType.js +17 -35
- package/v0/protocol/common/data/metadata/v14/registry/MetadataV14PortableType.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14SiField.js +20 -38
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14SiField.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14SiType.js +22 -40
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14SiType.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14SiTypeParameter.js +16 -34
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14SiTypeParameter.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14SiVariant.js +21 -39
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14SiVariant.js.map +1 -1
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14TypeDef.js +106 -150
- package/v0/protocol/common/data/metadata/v14/registry/si/MetadataV14TypeDef.js.map +1 -1
- package/v0/protocol/common/data/scale/SCALEDecoder.d.ts +2 -3
- package/v0/protocol/common/data/scale/SCALEDecoder.js +69 -74
- package/v0/protocol/common/data/scale/SCALEDecoder.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEAccountId.d.ts +0 -1
- package/v0/protocol/common/data/scale/type/SCALEAccountId.js +25 -44
- package/v0/protocol/common/data/scale/type/SCALEAccountId.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEArray.js +27 -45
- package/v0/protocol/common/data/scale/type/SCALEArray.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEBoolean.js +18 -36
- package/v0/protocol/common/data/scale/type/SCALEBoolean.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEBytes.d.ts +0 -1
- package/v0/protocol/common/data/scale/type/SCALEBytes.js +23 -42
- package/v0/protocol/common/data/scale/type/SCALEBytes.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEClass.js +8 -28
- package/v0/protocol/common/data/scale/type/SCALEClass.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALECompactInt.d.ts +1 -1
- package/v0/protocol/common/data/scale/type/SCALECompactInt.js +54 -73
- package/v0/protocol/common/data/scale/type/SCALECompactInt.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEData.d.ts +0 -1
- package/v0/protocol/common/data/scale/type/SCALEData.js +33 -51
- package/v0/protocol/common/data/scale/type/SCALEData.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEEnum.js +21 -39
- package/v0/protocol/common/data/scale/type/SCALEEnum.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEEra.js +46 -68
- package/v0/protocol/common/data/scale/type/SCALEEra.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEHash.d.ts +0 -1
- package/v0/protocol/common/data/scale/type/SCALEHash.js +29 -53
- package/v0/protocol/common/data/scale/type/SCALEHash.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEInt.d.ts +1 -1
- package/v0/protocol/common/data/scale/type/SCALEInt.js +46 -65
- package/v0/protocol/common/data/scale/type/SCALEInt.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEMultiAddress.d.ts +1 -2
- package/v0/protocol/common/data/scale/type/SCALEMultiAddress.js +40 -59
- package/v0/protocol/common/data/scale/type/SCALEMultiAddress.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEOptional.js +27 -47
- package/v0/protocol/common/data/scale/type/SCALEOptional.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEString.js +25 -44
- package/v0/protocol/common/data/scale/type/SCALEString.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALETuple.js +22 -40
- package/v0/protocol/common/data/scale/type/SCALETuple.js.map +1 -1
- package/v0/protocol/common/data/scale/type/SCALEType.js +6 -9
- package/v0/protocol/common/data/scale/type/SCALEType.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateActiveEraInfo.js +11 -12
- package/v0/protocol/common/data/staking/SubstrateActiveEraInfo.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateEraElectionStatus.js +14 -15
- package/v0/protocol/common/data/staking/SubstrateEraElectionStatus.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateEraRewardPoints.js +13 -16
- package/v0/protocol/common/data/staking/SubstrateEraRewardPoints.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateExposure.js +14 -17
- package/v0/protocol/common/data/staking/SubstrateExposure.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateNominationStatus.js +1 -1
- package/v0/protocol/common/data/staking/SubstrateNominationStatus.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateNominations.js +12 -13
- package/v0/protocol/common/data/staking/SubstrateNominations.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateNominatorDetails.d.ts +1 -1
- package/v0/protocol/common/data/staking/SubstratePayee.js +1 -1
- package/v0/protocol/common/data/staking/SubstratePayee.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateSlashingSpans.js +13 -14
- package/v0/protocol/common/data/staking/SubstrateSlashingSpans.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateStakingActionType.js +1 -1
- package/v0/protocol/common/data/staking/SubstrateStakingActionType.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateStakingLedger.js +16 -19
- package/v0/protocol/common/data/staking/SubstrateStakingLedger.js.map +1 -1
- package/v0/protocol/common/data/staking/SubstrateValidatorDetails.d.ts +1 -1
- package/v0/protocol/common/data/staking/SubstrateValidatorPrefs.js +9 -10
- package/v0/protocol/common/data/staking/SubstrateValidatorPrefs.js.map +1 -1
- package/v0/protocol/common/data/transaction/SubstrateSignature.d.ts +0 -1
- package/v0/protocol/common/data/transaction/SubstrateSignature.js +30 -53
- package/v0/protocol/common/data/transaction/SubstrateSignature.js.map +1 -1
- package/v0/protocol/common/data/transaction/SubstrateTransaction.d.ts +1 -1
- package/v0/protocol/common/data/transaction/SubstrateTransaction.js +53 -73
- package/v0/protocol/common/data/transaction/SubstrateTransaction.js.map +1 -1
- package/v0/protocol/common/data/transaction/SubstrateTransactionPayload.js +44 -76
- package/v0/protocol/common/data/transaction/SubstrateTransactionPayload.js.map +1 -1
- package/v0/protocol/common/data/transaction/method/SubstrateTransactionMethod.js +40 -76
- package/v0/protocol/common/data/transaction/method/SubstrateTransactionMethod.js.map +1 -1
- package/v0/protocol/common/data/transaction/method/SubstrateTransactionMethodArgs.js +360 -631
- package/v0/protocol/common/data/transaction/method/SubstrateTransactionMethodArgs.js.map +1 -1
- package/v0/protocol/common/node/SubstrateNodeClient.js +226 -533
- package/v0/protocol/common/node/SubstrateNodeClient.js.map +1 -1
- package/v0/protocol/common/node/supported.d.ts +9 -9
- package/v0/protocol/common/node/supported.js +1 -1
- package/v0/protocol/common/node/supported.js.map +1 -1
- package/v0/protocol/compat/SubstrateCompatAddress.d.ts +1 -2
- package/v0/protocol/compat/SubstrateCompatAddress.js +17 -30
- package/v0/protocol/compat/SubstrateCompatAddress.js.map +1 -1
- package/v0/protocol/compat/SubstrateCompatSignature.d.ts +0 -1
- package/v0/protocol/compat/SubstrateCompatSignature.js +4 -5
- package/v0/protocol/compat/SubstrateCompatSignature.js.map +1 -1
- package/v0/protocol/kusama/KusamaAddress.js +7 -27
- package/v0/protocol/kusama/KusamaAddress.js.map +1 -1
- package/v0/protocol/moonbeam/MoonbeamAddress.d.ts +0 -1
- package/v0/protocol/moonbeam/MoonbeamAddress.js +45 -36
- package/v0/protocol/moonbeam/MoonbeamAddress.js.map +1 -1
- package/v0/protocol/moonbeam/MoonbeamSignature.d.ts +0 -1
- package/v0/protocol/moonbeam/MoonbeamSignature.js +16 -35
- package/v0/protocol/moonbeam/MoonbeamSignature.js.map +1 -1
- package/v0/protocol/polkadot/PolkadotAddress.js +7 -27
- package/v0/protocol/polkadot/PolkadotAddress.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +30 -83
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +54 -133
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v0/utils/sr25519.js +26 -74
- package/v0/utils/sr25519.js.map +1 -1
- package/v1/block-explorer/subscan/SubscanBlockExplorer.js +12 -61
- package/v1/block-explorer/subscan/SubscanBlockExplorer.js.map +1 -1
- package/v1/block-explorer/subscan/SubscanBlockExplorerClient.js +55 -103
- package/v1/block-explorer/subscan/SubscanBlockExplorerClient.js.map +1 -1
- package/v1/controller/account/SubstrateCommonAccountController.js +65 -132
- package/v1/controller/account/SubstrateCommonAccountController.js.map +1 -1
- package/v1/controller/transaction/SubstrateCommonTransactionController.js +194 -356
- package/v1/controller/transaction/SubstrateCommonTransactionController.js.map +1 -1
- package/v1/crypto/SubstrateCryptoClient.js +23 -94
- package/v1/crypto/SubstrateCryptoClient.js.map +1 -1
- package/v1/data/account/SubstrateAccountInfo.js +27 -29
- package/v1/data/account/SubstrateAccountInfo.js.map +1 -1
- package/v1/data/account/SubstrateRegistration.js +50 -56
- package/v1/data/account/SubstrateRegistration.js.map +1 -1
- package/v1/data/account/address/SubstrateAddress.d.ts +1 -2
- package/v1/data/account/address/SubstrateAddress.js +2 -3
- package/v1/data/account/address/SubstrateAddress.js.map +1 -1
- package/v1/data/account/address/SubstrateAddressFactory.d.ts +2 -3
- package/v1/data/account/address/SubstrateAddressFactory.js +16 -23
- package/v1/data/account/address/SubstrateAddressFactory.js.map +1 -1
- package/v1/data/account/address/SubstrateEthAddress.d.ts +0 -1
- package/v1/data/account/address/SubstrateEthAddress.js +48 -39
- package/v1/data/account/address/SubstrateEthAddress.js.map +1 -1
- package/v1/data/account/address/SubstrateSS58Address.d.ts +0 -1
- package/v1/data/account/address/SubstrateSS58Address.js +47 -50
- package/v1/data/account/address/SubstrateSS58Address.js.map +1 -1
- package/v1/data/metadata/Metadata.js +24 -25
- package/v1/data/metadata/Metadata.js.map +1 -1
- package/v1/data/metadata/MetadataVersioned.js +2 -5
- package/v1/data/metadata/MetadataVersioned.js.map +1 -1
- package/v1/data/metadata/decorator/MetadataDecorator.js +18 -20
- package/v1/data/metadata/decorator/MetadataDecorator.js.map +1 -1
- package/v1/data/metadata/decorator/constant/SubstrateConstant.d.ts +0 -1
- package/v1/data/metadata/decorator/storage/SubstrateStorageEntry.js +89 -237
- package/v1/data/metadata/decorator/storage/SubstrateStorageEntry.js.map +1 -1
- package/v1/data/metadata/v11/MetadataV11.js +43 -63
- package/v1/data/metadata/v11/MetadataV11.js.map +1 -1
- package/v1/data/metadata/v11/module/MetadataV11Call.js +30 -51
- package/v1/data/metadata/v11/module/MetadataV11Call.js.map +1 -1
- package/v1/data/metadata/v11/module/MetadataV11Constant.js +20 -38
- package/v1/data/metadata/v11/module/MetadataV11Constant.js.map +1 -1
- package/v1/data/metadata/v11/module/MetadataV11Error.js +16 -34
- package/v1/data/metadata/v11/module/MetadataV11Error.js.map +1 -1
- package/v1/data/metadata/v11/module/MetadataV11Event.js +18 -36
- package/v1/data/metadata/v11/module/MetadataV11Event.js.map +1 -1
- package/v1/data/metadata/v11/module/MetadataV11Module.js +29 -51
- package/v1/data/metadata/v11/module/MetadataV11Module.js.map +1 -1
- package/v1/data/metadata/v11/module/storage/MetadataV11Storage.js +17 -35
- package/v1/data/metadata/v11/module/storage/MetadataV11Storage.js.map +1 -1
- package/v1/data/metadata/v11/module/storage/MetadataV11StorageEntry.js +23 -41
- package/v1/data/metadata/v11/module/storage/MetadataV11StorageEntry.js.map +1 -1
- package/v1/data/metadata/v11/module/storage/MetadataV11StorageEntryType.js +72 -114
- package/v1/data/metadata/v11/module/storage/MetadataV11StorageEntryType.js.map +1 -1
- package/v1/data/metadata/v12/MetadataV12.js +41 -61
- package/v1/data/metadata/v12/MetadataV12.js.map +1 -1
- package/v1/data/metadata/v12/module/MetadataV12Module.js +14 -32
- package/v1/data/metadata/v12/module/MetadataV12Module.js.map +1 -1
- package/v1/data/metadata/v13/MetadataV13.js +41 -61
- package/v1/data/metadata/v13/MetadataV13.js.map +1 -1
- package/v1/data/metadata/v13/module/MetadataV13Module.js +31 -53
- package/v1/data/metadata/v13/module/MetadataV13Module.js.map +1 -1
- package/v1/data/metadata/v13/module/storage/MetadataV13Storage.js +17 -35
- package/v1/data/metadata/v13/module/storage/MetadataV13Storage.js.map +1 -1
- package/v1/data/metadata/v13/module/storage/MetadataV13StorageEntry.js +23 -41
- package/v1/data/metadata/v13/module/storage/MetadataV13StorageEntry.js.map +1 -1
- package/v1/data/metadata/v13/module/storage/MetadataV13StorageEntryType.js +83 -130
- package/v1/data/metadata/v13/module/storage/MetadataV13StorageEntryType.js.map +1 -1
- package/v1/data/metadata/v14/MetadataV14.js +53 -74
- package/v1/data/metadata/v14/MetadataV14.js.map +1 -1
- package/v1/data/metadata/v14/MetadataV14Component.js +7 -25
- package/v1/data/metadata/v14/MetadataV14Component.js.map +1 -1
- package/v1/data/metadata/v14/extrinsic/MetadataV14Extrinsic.js +17 -35
- package/v1/data/metadata/v14/extrinsic/MetadataV14Extrinsic.js.map +1 -1
- package/v1/data/metadata/v14/extrinsic/MetadataV14SignedExtension.js +16 -34
- package/v1/data/metadata/v14/extrinsic/MetadataV14SignedExtension.js.map +1 -1
- package/v1/data/metadata/v14/pallet/MetadataV14Call.js +8 -28
- package/v1/data/metadata/v14/pallet/MetadataV14Call.js.map +1 -1
- package/v1/data/metadata/v14/pallet/MetadataV14Constant.js +19 -37
- package/v1/data/metadata/v14/pallet/MetadataV14Constant.js.map +1 -1
- package/v1/data/metadata/v14/pallet/MetadataV14Error.js +8 -28
- package/v1/data/metadata/v14/pallet/MetadataV14Error.js.map +1 -1
- package/v1/data/metadata/v14/pallet/MetadataV14Event.js +8 -28
- package/v1/data/metadata/v14/pallet/MetadataV14Event.js.map +1 -1
- package/v1/data/metadata/v14/pallet/MetadataV14Pallet.js +30 -48
- package/v1/data/metadata/v14/pallet/MetadataV14Pallet.js.map +1 -1
- package/v1/data/metadata/v14/pallet/storage/MetadataV14Storage.js +16 -34
- package/v1/data/metadata/v14/pallet/storage/MetadataV14Storage.js.map +1 -1
- package/v1/data/metadata/v14/pallet/storage/MetadataV14StorageEntry.js +23 -41
- package/v1/data/metadata/v14/pallet/storage/MetadataV14StorageEntry.js.map +1 -1
- package/v1/data/metadata/v14/pallet/storage/MetadataV14StorageEntryType.js +49 -90
- package/v1/data/metadata/v14/pallet/storage/MetadataV14StorageEntryType.js.map +1 -1
- package/v1/data/metadata/v14/registry/MetadataV14PortableRegistry.js +20 -41
- package/v1/data/metadata/v14/registry/MetadataV14PortableRegistry.js.map +1 -1
- package/v1/data/metadata/v14/registry/MetadataV14PortableType.js +17 -35
- package/v1/data/metadata/v14/registry/MetadataV14PortableType.js.map +1 -1
- package/v1/data/metadata/v14/registry/si/MetadataV14SiField.js +20 -38
- package/v1/data/metadata/v14/registry/si/MetadataV14SiField.js.map +1 -1
- package/v1/data/metadata/v14/registry/si/MetadataV14SiType.js +22 -40
- package/v1/data/metadata/v14/registry/si/MetadataV14SiType.js.map +1 -1
- package/v1/data/metadata/v14/registry/si/MetadataV14SiTypeParameter.js +16 -34
- package/v1/data/metadata/v14/registry/si/MetadataV14SiTypeParameter.js.map +1 -1
- package/v1/data/metadata/v14/registry/si/MetadataV14SiVariant.js +21 -39
- package/v1/data/metadata/v14/registry/si/MetadataV14SiVariant.js.map +1 -1
- package/v1/data/metadata/v14/registry/si/MetadataV14TypeDef.js +106 -150
- package/v1/data/metadata/v14/registry/si/MetadataV14TypeDef.js.map +1 -1
- package/v1/data/scale/SCALEDecoder.d.ts +2 -3
- package/v1/data/scale/SCALEDecoder.js +69 -80
- package/v1/data/scale/SCALEDecoder.js.map +1 -1
- package/v1/data/scale/type/SCALEAccountId.d.ts +0 -1
- package/v1/data/scale/type/SCALEAccountId.js +27 -46
- package/v1/data/scale/type/SCALEAccountId.js.map +1 -1
- package/v1/data/scale/type/SCALEArray.js +27 -45
- package/v1/data/scale/type/SCALEArray.js.map +1 -1
- package/v1/data/scale/type/SCALEBoolean.js +18 -36
- package/v1/data/scale/type/SCALEBoolean.js.map +1 -1
- package/v1/data/scale/type/SCALEBytes.d.ts +0 -1
- package/v1/data/scale/type/SCALEBytes.js +23 -42
- package/v1/data/scale/type/SCALEBytes.js.map +1 -1
- package/v1/data/scale/type/SCALEClass.js +8 -28
- package/v1/data/scale/type/SCALEClass.js.map +1 -1
- package/v1/data/scale/type/SCALECompactInt.d.ts +1 -1
- package/v1/data/scale/type/SCALECompactInt.js +54 -73
- package/v1/data/scale/type/SCALECompactInt.js.map +1 -1
- package/v1/data/scale/type/SCALEData.d.ts +0 -1
- package/v1/data/scale/type/SCALEData.js +33 -51
- package/v1/data/scale/type/SCALEData.js.map +1 -1
- package/v1/data/scale/type/SCALEEnum.js +21 -39
- package/v1/data/scale/type/SCALEEnum.js.map +1 -1
- package/v1/data/scale/type/SCALEEra.js +46 -68
- package/v1/data/scale/type/SCALEEra.js.map +1 -1
- package/v1/data/scale/type/SCALEHash.d.ts +0 -1
- package/v1/data/scale/type/SCALEHash.js +29 -53
- package/v1/data/scale/type/SCALEHash.js.map +1 -1
- package/v1/data/scale/type/SCALEInt.d.ts +1 -1
- package/v1/data/scale/type/SCALEInt.js +46 -65
- package/v1/data/scale/type/SCALEInt.js.map +1 -1
- package/v1/data/scale/type/SCALEMultiAddress.d.ts +1 -2
- package/v1/data/scale/type/SCALEMultiAddress.js +40 -59
- package/v1/data/scale/type/SCALEMultiAddress.js.map +1 -1
- package/v1/data/scale/type/SCALEOptional.js +27 -47
- package/v1/data/scale/type/SCALEOptional.js.map +1 -1
- package/v1/data/scale/type/SCALEString.js +25 -44
- package/v1/data/scale/type/SCALEString.js.map +1 -1
- package/v1/data/scale/type/SCALETuple.js +22 -40
- package/v1/data/scale/type/SCALETuple.js.map +1 -1
- package/v1/data/scale/type/SCALEType.js +6 -9
- package/v1/data/scale/type/SCALEType.js.map +1 -1
- package/v1/data/transaction/SubstrateSignature.d.ts +0 -1
- package/v1/data/transaction/SubstrateSignature.js +36 -61
- package/v1/data/transaction/SubstrateSignature.js.map +1 -1
- package/v1/data/transaction/SubstrateTransaction.d.ts +2 -2
- package/v1/data/transaction/SubstrateTransaction.js +66 -87
- package/v1/data/transaction/SubstrateTransaction.js.map +1 -1
- package/v1/data/transaction/SubstrateTransactionPayload.js +81 -114
- package/v1/data/transaction/SubstrateTransactionPayload.js.map +1 -1
- package/v1/data/transaction/method/SubstrateTransactionMethod.js +40 -76
- package/v1/data/transaction/method/SubstrateTransactionMethod.js.map +1 -1
- package/v1/data/transaction/method/SubstrateTransactionMethodArgs.js +35 -65
- package/v1/data/transaction/method/SubstrateTransactionMethodArgs.js.map +1 -1
- package/v1/index.js +38 -38
- package/v1/index.js.map +1 -1
- package/v1/node/SubstrateCommonNodeClient.d.ts +12 -12
- package/v1/node/SubstrateCommonNodeClient.js +159 -357
- package/v1/node/SubstrateCommonNodeClient.js.map +1 -1
- package/v1/protocol/SubstrateProtocol.d.ts +2 -4
- package/v1/protocol/SubstrateProtocol.js +182 -410
- package/v1/protocol/SubstrateProtocol.js.map +1 -1
- package/v1/protocol/SubstrateStakingProtocol.js +15 -82
- package/v1/protocol/SubstrateStakingProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +8 -20
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +15 -63
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +48 -129
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/configuration.d.ts +6 -6
- package/v1/types/crypto.d.ts +1 -1
- package/v1/utils/keys.js +4 -5
- package/v1/utils/keys.js.map +1 -1
- package/v1/utils/protocol.js +14 -15
- package/v1/utils/protocol.js.map +1 -1
- package/v1/utils/signature.js +3 -4
- package/v1/utils/signature.js.map +1 -1
|
@@ -1,81 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
6
|
exports.SubstrateNodeClient = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (storageEntries === void 0) { storageEntries = supported_1.supportedStorageEntries; }
|
|
75
|
-
if (calls === void 0) { calls = supported_1.supportedCalls; }
|
|
76
|
-
if (constants === void 0) { constants = supported_1.supportedConstants; }
|
|
77
|
-
if (callEndpoints === void 0) { callEndpoints = supported_1.supportedCallEndpoints; }
|
|
78
|
-
if (cache === void 0) { cache = new cache_1.Cache(CACHE_DEFAULT_EXPIRATION_TIME); }
|
|
7
|
+
const RPCBody_1 = require("@airgap/coinlib-core/data/RPCBody");
|
|
8
|
+
const axios_0_19_0_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0"));
|
|
9
|
+
const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
10
|
+
const cache_1 = require("@airgap/coinlib-core/utils/cache");
|
|
11
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
12
|
+
const coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
13
|
+
const hex_1 = require("@airgap/coinlib-core/utils/hex");
|
|
14
|
+
const SubstrateAccountInfo_1 = require("../data/account/SubstrateAccountInfo");
|
|
15
|
+
const SubstrateRegistration_1 = require("../data/account/SubstrateRegistration");
|
|
16
|
+
const Metadata_1 = require("../data/metadata/Metadata");
|
|
17
|
+
const SCALEAccountId_1 = require("../data/scale/type/SCALEAccountId");
|
|
18
|
+
const SCALEArray_1 = require("../data/scale/type/SCALEArray");
|
|
19
|
+
const SCALECompactInt_1 = require("../data/scale/type/SCALECompactInt");
|
|
20
|
+
const SCALEData_1 = require("../data/scale/type/SCALEData");
|
|
21
|
+
const SCALEEnum_1 = require("../data/scale/type/SCALEEnum");
|
|
22
|
+
const SCALEInt_1 = require("../data/scale/type/SCALEInt");
|
|
23
|
+
const SCALETuple_1 = require("../data/scale/type/SCALETuple");
|
|
24
|
+
const SubstrateActiveEraInfo_1 = require("../data/staking/SubstrateActiveEraInfo");
|
|
25
|
+
const SubstrateEraElectionStatus_1 = require("../data/staking/SubstrateEraElectionStatus");
|
|
26
|
+
const SubstrateEraRewardPoints_1 = require("../data/staking/SubstrateEraRewardPoints");
|
|
27
|
+
const SubstrateExposure_1 = require("../data/staking/SubstrateExposure");
|
|
28
|
+
const SubstrateNominations_1 = require("../data/staking/SubstrateNominations");
|
|
29
|
+
const SubstratePayee_1 = require("../data/staking/SubstratePayee");
|
|
30
|
+
const SubstrateSlashingSpans_1 = require("../data/staking/SubstrateSlashingSpans");
|
|
31
|
+
const SubstrateStakingLedger_1 = require("../data/staking/SubstrateStakingLedger");
|
|
32
|
+
const SubstrateValidatorPrefs_1 = require("../data/staking/SubstrateValidatorPrefs");
|
|
33
|
+
const supported_1 = require("./supported");
|
|
34
|
+
const CACHE_DEFAULT_EXPIRATION_TIME = 3000; // 3s
|
|
35
|
+
const MAX_RETRIES = 3;
|
|
36
|
+
class SubstrateNodeClient {
|
|
37
|
+
constructor(network, baseURL, storageEntries = supported_1.supportedStorageEntries, calls = supported_1.supportedCalls, constants = supported_1.supportedConstants, callEndpoints = supported_1.supportedCallEndpoints, cache = new cache_1.Cache(CACHE_DEFAULT_EXPIRATION_TIME)) {
|
|
79
38
|
this.network = network;
|
|
80
39
|
this.baseURL = baseURL;
|
|
81
40
|
this.storageEntries = storageEntries;
|
|
@@ -86,475 +45,209 @@ var SubstrateNodeClient = /** @class */ (function () {
|
|
|
86
45
|
this.lastFees = new Map();
|
|
87
46
|
this.initApiPromise = null;
|
|
88
47
|
}
|
|
89
|
-
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
var _a, methodName, callName, call;
|
|
109
|
-
return __generator(this, function (_b) {
|
|
110
|
-
switch (_b.label) {
|
|
111
|
-
case 0:
|
|
112
|
-
_a = this.callEndpoints.get(type) || [null, null], methodName = _a[0], callName = _a[1];
|
|
113
|
-
call = null;
|
|
114
|
-
if (!(methodName && callName)) return [3 /*break*/, 2];
|
|
115
|
-
return [4 /*yield*/, this.getCall(methodName, callName)];
|
|
116
|
-
case 1:
|
|
117
|
-
call = _b.sent();
|
|
118
|
-
_b.label = 2;
|
|
119
|
-
case 2: return [2 /*return*/, call ? call : Promise.reject('Could not find requested transaction.')];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
SubstrateNodeClient.prototype.getTransferFeeEstimate = function (transaction) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
return __generator(this, function (_a) {
|
|
127
|
-
return [2 /*return*/, this.send('payment', 'queryInfo', [(0, hex_1.bytesToHex)(transaction)]).then(function (result) { return (result ? new bignumber_1.default(result.partialFee) : null); })];
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
SubstrateNodeClient.prototype.saveLastFee = function (type, fee) {
|
|
48
|
+
async getAccountInfo(address) {
|
|
49
|
+
return this.fromStorage('System', 'Account', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item ? SubstrateAccountInfo_1.SubstrateAccountInfo.decode(this.network, this.runtimeVersion, item) : null);
|
|
50
|
+
}
|
|
51
|
+
async getExistentialDeposit() {
|
|
52
|
+
return this.getConstant('Balances', 'ExistentialDeposit').then((constant) => SCALEInt_1.SCALEInt.decode(constant).decoded.value);
|
|
53
|
+
}
|
|
54
|
+
async getTransactionMetadata(type) {
|
|
55
|
+
const [methodName, callName] = this.callEndpoints.get(type) || [null, null];
|
|
56
|
+
let call = null;
|
|
57
|
+
if (methodName && callName) {
|
|
58
|
+
call = await this.getCall(methodName, callName);
|
|
59
|
+
}
|
|
60
|
+
return call ? call : Promise.reject('Could not find requested transaction.');
|
|
61
|
+
}
|
|
62
|
+
async getTransferFeeEstimate(transaction) {
|
|
63
|
+
return this.send('payment', 'queryInfo', [(0, hex_1.bytesToHex)(transaction)]).then((result) => (result ? new bignumber_1.default(result.partialFee) : null));
|
|
64
|
+
}
|
|
65
|
+
saveLastFee(type, fee) {
|
|
132
66
|
this.lastFees.set(type, fee);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
var fee = this.lastFees.get(type) || null;
|
|
67
|
+
}
|
|
68
|
+
getSavedLastFee(type, defaultValue = 'null') {
|
|
69
|
+
let fee = this.lastFees.get(type) || null;
|
|
137
70
|
if (!fee && defaultValue === 'largest') {
|
|
138
|
-
|
|
139
|
-
fee = savedFees.length > 0 ? bignumber_1.default.max
|
|
71
|
+
const savedFees = Array.from(this.lastFees.values());
|
|
72
|
+
fee = savedFees.length > 0 ? bignumber_1.default.max(...savedFees) : null;
|
|
140
73
|
}
|
|
141
74
|
return fee;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
SubstrateNodeClient.prototype.getStakersClipped = function (eraIndex, validator) {
|
|
218
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
219
|
-
var _this = this;
|
|
220
|
-
return __generator(this, function (_a) {
|
|
221
|
-
return [2 /*return*/, this.fromStorage('Staking', 'ErasStakersClipped', SCALEInt_1.SCALEInt.from(eraIndex, 32), SCALEAccountId_1.SCALEAccountId.from(validator, this.network)).then(function (item) { return (item ? SubstrateExposure_1.SubstrateExposure.decode(_this.network, _this.runtimeVersion, item) : null); })];
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
};
|
|
225
|
-
SubstrateNodeClient.prototype.getRewardDestination = function (address) {
|
|
226
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
-
return __generator(this, function (_a) {
|
|
228
|
-
return [2 /*return*/, this.fromStorage('Staking', 'Payee', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then(function (item) {
|
|
229
|
-
return item ? SCALEEnum_1.SCALEEnum.decode(item, function (hex) { return SubstratePayee_1.SubstratePayee[SubstratePayee_1.SubstratePayee[hex]]; }).decoded.value : null;
|
|
230
|
-
})];
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
SubstrateNodeClient.prototype.getStakingLedger = function (address) {
|
|
235
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
236
|
-
var _this = this;
|
|
237
|
-
return __generator(this, function (_a) {
|
|
238
|
-
return [2 /*return*/, this.fromStorage('Staking', 'Ledger', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then(function (item) {
|
|
239
|
-
return item ? SubstrateStakingLedger_1.SubstrateStakingLedger.decode(_this.network, _this.runtimeVersion, item) : null;
|
|
240
|
-
})];
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
SubstrateNodeClient.prototype.getValidators = function () {
|
|
245
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
-
var _this = this;
|
|
247
|
-
return __generator(this, function (_a) {
|
|
248
|
-
return [2 /*return*/, this.fromStorage('Session', 'Validators').then(function (items) {
|
|
249
|
-
return items
|
|
250
|
-
? SCALEArray_1.SCALEArray.decode(_this.network, _this.runtimeVersion, items, function (network, _, hex) {
|
|
251
|
-
return SCALEAccountId_1.SCALEAccountId.decode(network, hex);
|
|
252
|
-
}).decoded.elements.map(function (encoded) { return encoded.address; })
|
|
253
|
-
: null;
|
|
254
|
-
})];
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
};
|
|
258
|
-
SubstrateNodeClient.prototype.getValidatorExposure = function (eraIndex, address) {
|
|
259
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
260
|
-
var _this = this;
|
|
261
|
-
return __generator(this, function (_a) {
|
|
262
|
-
return [2 /*return*/, this.fromStorage('Staking', 'ErasStakers', SCALEInt_1.SCALEInt.from(eraIndex, 32), SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then(function (item) { return (item ? SubstrateExposure_1.SubstrateExposure.decode(_this.network, _this.runtimeVersion, item) : null); })];
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
};
|
|
266
|
-
SubstrateNodeClient.prototype.getElectionStatus = function () {
|
|
267
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
268
|
-
var _this = this;
|
|
269
|
-
return __generator(this, function (_a) {
|
|
270
|
-
return [2 /*return*/, this.fromStorage('Staking', 'EraElectionStatus').then(function (item) {
|
|
271
|
-
return item ? SubstrateEraElectionStatus_1.SubstrateEraElectionStatus.decode(_this.network, _this.runtimeVersion, item) : null;
|
|
272
|
-
})];
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
SubstrateNodeClient.prototype.getIdentityOf = function (address) {
|
|
277
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
278
|
-
var _this = this;
|
|
279
|
-
return __generator(this, function (_a) {
|
|
280
|
-
return [2 /*return*/, this.fromStorage('Identity', 'IdentityOf', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then(function (item) {
|
|
281
|
-
return item ? SubstrateRegistration_1.SubstrateRegistration.decode(_this.network, _this.runtimeVersion, item) : null;
|
|
282
|
-
})];
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
SubstrateNodeClient.prototype.getSuperOf = function (address) {
|
|
287
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
-
var _this = this;
|
|
289
|
-
return __generator(this, function (_a) {
|
|
290
|
-
return [2 /*return*/, this.fromStorage('Identity', 'SuperOf', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then(function (item) {
|
|
291
|
-
return item
|
|
292
|
-
? SCALETuple_1.SCALETuple.decode(_this.network, _this.runtimeVersion, item, function (network, _, hex) { return SCALEAccountId_1.SCALEAccountId.decode(network, hex); }, function (_network, _runtimeVersion, hex) { return SCALEData_1.SCALEData.decode(hex); }).decoded
|
|
293
|
-
: null;
|
|
294
|
-
})];
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
};
|
|
298
|
-
SubstrateNodeClient.prototype.getSubsOf = function (address) {
|
|
299
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
300
|
-
var _this = this;
|
|
301
|
-
return __generator(this, function (_a) {
|
|
302
|
-
return [2 /*return*/, this.fromStorage('Identity', 'SubsOf', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then(function (item) {
|
|
303
|
-
return item
|
|
304
|
-
? SCALETuple_1.SCALETuple.decode(_this.network, _this.runtimeVersion, item, function (_network, _runtimeVersion, hex) { return SCALECompactInt_1.SCALECompactInt.decode(hex); }, function (network, _, hex) {
|
|
305
|
-
return SCALEArray_1.SCALEArray.decode(network, _, hex, function (innerNetwork, _, innerHex) { return SCALEAccountId_1.SCALEAccountId.decode(innerNetwork, innerHex); });
|
|
306
|
-
}).decoded
|
|
307
|
-
: null;
|
|
308
|
-
})];
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
SubstrateNodeClient.prototype.getValidatorPrefs = function (eraIndex, address) {
|
|
313
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
-
var _this = this;
|
|
315
|
-
return __generator(this, function (_a) {
|
|
316
|
-
return [2 /*return*/, this.fromStorage('Staking', 'ErasValidatorPrefs', SCALEInt_1.SCALEInt.from(eraIndex, 32), SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then(function (item) { return (item ? SubstrateValidatorPrefs_1.SubstrateValidatorPrefs.decode(_this.network, _this.runtimeVersion, item) : null); })];
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
SubstrateNodeClient.prototype.getExpectedEraDuration = function () {
|
|
321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
-
var constants, expectedBlockTime, epochDuration, sessionsPerEra;
|
|
323
|
-
return __generator(this, function (_a) {
|
|
324
|
-
switch (_a.label) {
|
|
325
|
-
case 0: return [4 /*yield*/, Promise.all([
|
|
326
|
-
this.getConstant('Babe', 'ExpectedBlockTime'),
|
|
327
|
-
this.getConstant('Babe', 'EpochDuration'),
|
|
328
|
-
this.getConstant('Staking', 'SessionsPerEra')
|
|
329
|
-
]).then(function (constants) { return constants.map(function (constant) { return (constant ? SCALEInt_1.SCALEInt.decode(constant).decoded.value : null); }); })];
|
|
330
|
-
case 1:
|
|
331
|
-
constants = _a.sent();
|
|
332
|
-
if (constants.some(function (constant) { return constant === null; })) {
|
|
333
|
-
return [2 /*return*/, null];
|
|
334
|
-
}
|
|
335
|
-
expectedBlockTime = constants[0];
|
|
336
|
-
epochDuration = constants[1];
|
|
337
|
-
sessionsPerEra = constants[2];
|
|
338
|
-
return [2 /*return*/, expectedBlockTime.multipliedBy(epochDuration).multipliedBy(sessionsPerEra)];
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
SubstrateNodeClient.prototype.getActiveEraInfo = function () {
|
|
344
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
345
|
-
var _this = this;
|
|
346
|
-
return __generator(this, function (_a) {
|
|
347
|
-
return [2 /*return*/, this.fromStorage('Staking', 'ActiveEra').then(function (item) {
|
|
348
|
-
return item ? SubstrateActiveEraInfo_1.SubstrateActiveEraInfo.decode(_this.network, _this.runtimeVersion, item) : null;
|
|
349
|
-
})];
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
};
|
|
353
|
-
SubstrateNodeClient.prototype.getSlashingSpan = function (address) {
|
|
354
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
355
|
-
var _this = this;
|
|
356
|
-
return __generator(this, function (_a) {
|
|
357
|
-
return [2 /*return*/, this.fromStorage('Staking', 'SlashingSpans', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then(function (item) {
|
|
358
|
-
return item ? SubstrateSlashingSpans_1.SubstrateSlashingSpans.decode(_this.network, _this.runtimeVersion, item) : null;
|
|
359
|
-
})];
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
};
|
|
363
|
-
SubstrateNodeClient.prototype.submitTransaction = function (encoded) {
|
|
364
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
365
|
-
return __generator(this, function (_a) {
|
|
366
|
-
return [2 /*return*/, this.send('author', 'submitExtrinsic', [encoded], { allowCache: false })];
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
};
|
|
370
|
-
SubstrateNodeClient.prototype.getBlockHash = function (blockNumber) {
|
|
371
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
372
|
-
return __generator(this, function (_a) {
|
|
373
|
-
return [2 /*return*/, this.send('chain', 'getBlockHash', blockNumber !== undefined ? [(0, hex_1.toHexString)(blockNumber)] : [])];
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
};
|
|
377
|
-
SubstrateNodeClient.prototype.fromStorage = function (moduleName, entryName) {
|
|
378
|
-
var _a;
|
|
379
|
-
var args = [];
|
|
380
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
381
|
-
args[_i - 2] = arguments[_i];
|
|
75
|
+
}
|
|
76
|
+
async getFirstBlockHash() {
|
|
77
|
+
return this.getBlockHash(0);
|
|
78
|
+
}
|
|
79
|
+
async getLastBlockHash() {
|
|
80
|
+
return this.getBlockHash();
|
|
81
|
+
}
|
|
82
|
+
async getCurrentHeight() {
|
|
83
|
+
return this.send('chain', 'getBlock').then((result) => new bignumber_1.default((0, hex_1.stripHexPrefix)(result.block.header.number), 16));
|
|
84
|
+
}
|
|
85
|
+
async getCurrentEraIndex() {
|
|
86
|
+
return this.fromStorage('Staking', 'CurrentEra').then((item) => (item ? SCALEInt_1.SCALEInt.decode(item).decoded.value : null));
|
|
87
|
+
}
|
|
88
|
+
async getRuntimeVersion() {
|
|
89
|
+
return this.send('state', 'getRuntimeVersion').catch(() => null);
|
|
90
|
+
}
|
|
91
|
+
async getBonded(address) {
|
|
92
|
+
return this.fromStorage('Staking', 'Bonded', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item ? SCALEAccountId_1.SCALEAccountId.decode(this.network, item).decoded.address : null);
|
|
93
|
+
}
|
|
94
|
+
async getNominations(address) {
|
|
95
|
+
return this.fromStorage('Staking', 'Nominators', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item ? SubstrateNominations_1.SubstrateNominations.decode(this.network, this.runtimeVersion, item) : null);
|
|
96
|
+
}
|
|
97
|
+
async getRewardPoints(eraIndex) {
|
|
98
|
+
return this.fromStorage('Staking', 'ErasRewardPoints', SCALEInt_1.SCALEInt.from(eraIndex, 32)).then((item) => item ? SubstrateEraRewardPoints_1.SubstrateEraRewardPoints.decode(this.network, this.runtimeVersion, item) : null);
|
|
99
|
+
}
|
|
100
|
+
async getValidatorReward(eraIndex) {
|
|
101
|
+
return this.fromStorage('Staking', 'ErasValidatorReward', SCALEInt_1.SCALEInt.from(eraIndex, 32)).then((item) => item ? SCALEInt_1.SCALEInt.decode(item).decoded.value : null);
|
|
102
|
+
}
|
|
103
|
+
async getStakersClipped(eraIndex, validator) {
|
|
104
|
+
return this.fromStorage('Staking', 'ErasStakersClipped', SCALEInt_1.SCALEInt.from(eraIndex, 32), SCALEAccountId_1.SCALEAccountId.from(validator, this.network)).then((item) => (item ? SubstrateExposure_1.SubstrateExposure.decode(this.network, this.runtimeVersion, item) : null));
|
|
105
|
+
}
|
|
106
|
+
async getRewardDestination(address) {
|
|
107
|
+
return this.fromStorage('Staking', 'Payee', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item ? SCALEEnum_1.SCALEEnum.decode(item, (hex) => SubstratePayee_1.SubstratePayee[SubstratePayee_1.SubstratePayee[hex]]).decoded.value : null);
|
|
108
|
+
}
|
|
109
|
+
async getStakingLedger(address) {
|
|
110
|
+
return this.fromStorage('Staking', 'Ledger', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item ? SubstrateStakingLedger_1.SubstrateStakingLedger.decode(this.network, this.runtimeVersion, item) : null);
|
|
111
|
+
}
|
|
112
|
+
async getValidators() {
|
|
113
|
+
return this.fromStorage('Session', 'Validators').then((items) => items
|
|
114
|
+
? SCALEArray_1.SCALEArray.decode(this.network, this.runtimeVersion, items, (network, _, hex) => SCALEAccountId_1.SCALEAccountId.decode(network, hex)).decoded.elements.map((encoded) => encoded.address)
|
|
115
|
+
: null);
|
|
116
|
+
}
|
|
117
|
+
async getValidatorExposure(eraIndex, address) {
|
|
118
|
+
return this.fromStorage('Staking', 'ErasStakers', SCALEInt_1.SCALEInt.from(eraIndex, 32), SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => (item ? SubstrateExposure_1.SubstrateExposure.decode(this.network, this.runtimeVersion, item) : null));
|
|
119
|
+
}
|
|
120
|
+
async getElectionStatus() {
|
|
121
|
+
return this.fromStorage('Staking', 'EraElectionStatus').then((item) => item ? SubstrateEraElectionStatus_1.SubstrateEraElectionStatus.decode(this.network, this.runtimeVersion, item) : null);
|
|
122
|
+
}
|
|
123
|
+
async getIdentityOf(address) {
|
|
124
|
+
return this.fromStorage('Identity', 'IdentityOf', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item ? SubstrateRegistration_1.SubstrateRegistration.decode(this.network, this.runtimeVersion, item) : null);
|
|
125
|
+
}
|
|
126
|
+
async getSuperOf(address) {
|
|
127
|
+
return this.fromStorage('Identity', 'SuperOf', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item
|
|
128
|
+
? SCALETuple_1.SCALETuple.decode(this.network, this.runtimeVersion, item, (network, _, hex) => SCALEAccountId_1.SCALEAccountId.decode(network, hex), (_network, _runtimeVersion, hex) => SCALEData_1.SCALEData.decode(hex)).decoded
|
|
129
|
+
: null);
|
|
130
|
+
}
|
|
131
|
+
async getSubsOf(address) {
|
|
132
|
+
return this.fromStorage('Identity', 'SubsOf', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item
|
|
133
|
+
? SCALETuple_1.SCALETuple.decode(this.network, this.runtimeVersion, item, (_network, _runtimeVersion, hex) => SCALECompactInt_1.SCALECompactInt.decode(hex), (network, _, hex) => SCALEArray_1.SCALEArray.decode(network, _, hex, (innerNetwork, _, innerHex) => SCALEAccountId_1.SCALEAccountId.decode(innerNetwork, innerHex))).decoded
|
|
134
|
+
: null);
|
|
135
|
+
}
|
|
136
|
+
async getValidatorPrefs(eraIndex, address) {
|
|
137
|
+
return this.fromStorage('Staking', 'ErasValidatorPrefs', SCALEInt_1.SCALEInt.from(eraIndex, 32), SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => (item ? SubstrateValidatorPrefs_1.SubstrateValidatorPrefs.decode(this.network, this.runtimeVersion, item) : null));
|
|
138
|
+
}
|
|
139
|
+
async getExpectedEraDuration() {
|
|
140
|
+
const constants = await Promise.all([
|
|
141
|
+
this.getConstant('Babe', 'ExpectedBlockTime'),
|
|
142
|
+
this.getConstant('Babe', 'EpochDuration'),
|
|
143
|
+
this.getConstant('Staking', 'SessionsPerEra')
|
|
144
|
+
]).then((constants) => constants.map((constant) => (constant ? SCALEInt_1.SCALEInt.decode(constant).decoded.value : null)));
|
|
145
|
+
if (constants.some((constant) => constant === null)) {
|
|
146
|
+
return null;
|
|
382
147
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
case 0: return [4 /*yield*/, this.initApi()];
|
|
428
|
-
case 1:
|
|
429
|
-
_b.sent();
|
|
430
|
-
constant = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.constant(moduleName, constantName);
|
|
431
|
-
return [2 /*return*/, constant ? constant.value.toString('hex') : Promise.reject("Could not find requested item: ".concat(moduleName, " ").concat(constantName))];
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
});
|
|
435
|
-
};
|
|
436
|
-
SubstrateNodeClient.prototype.initApi = function () {
|
|
437
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
438
|
-
var initApiPromise_1;
|
|
439
|
-
var _this = this;
|
|
440
|
-
return __generator(this, function (_a) {
|
|
441
|
-
if (!this.initApiPromise) {
|
|
442
|
-
initApiPromise_1 = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
443
|
-
var _a, metadataEncoded, runtimeVersion;
|
|
444
|
-
return __generator(this, function (_b) {
|
|
445
|
-
switch (_b.label) {
|
|
446
|
-
case 0: return [4 /*yield*/, Promise.all([this.send('state', 'getMetadata'), this.getRuntimeVersion()])];
|
|
447
|
-
case 1:
|
|
448
|
-
_a = _b.sent(), metadataEncoded = _a[0], runtimeVersion = _a[1];
|
|
449
|
-
if (!runtimeVersion) {
|
|
450
|
-
reject('Could not fetch runtime version from the node');
|
|
451
|
-
}
|
|
452
|
-
this.metadata = Metadata_1.Metadata.decode(this.network, runtimeVersion === null || runtimeVersion === void 0 ? void 0 : runtimeVersion.specVersion, metadataEncoded).decorate(this.storageEntries, this.calls, this.constants);
|
|
453
|
-
this.runtimeVersion = runtimeVersion === null || runtimeVersion === void 0 ? void 0 : runtimeVersion.specVersion;
|
|
454
|
-
resolve();
|
|
455
|
-
return [2 /*return*/];
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}); }).then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
459
|
-
return __generator(this, function (_a) {
|
|
460
|
-
switch (_a.label) {
|
|
461
|
-
case 0:
|
|
462
|
-
this.initApiPromise = Promise.resolve();
|
|
463
|
-
return [4 /*yield*/, this.initCache()];
|
|
464
|
-
case 1:
|
|
465
|
-
_a.sent();
|
|
466
|
-
return [2 /*return*/];
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
}); });
|
|
470
|
-
this.initApiPromise = initApiPromise_1.catch(function (error) {
|
|
471
|
-
console.warn(error);
|
|
472
|
-
_this.initApiPromise = initApiPromise_1; // retry once
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
return [2 /*return*/, this.initApiPromise];
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
};
|
|
479
|
-
SubstrateNodeClient.prototype.initCache = function () {
|
|
480
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
481
|
-
var blockTime;
|
|
482
|
-
return __generator(this, function (_a) {
|
|
483
|
-
switch (_a.label) {
|
|
484
|
-
case 0: return [4 /*yield*/, this.getConstant('Babe', 'ExpectedBlockTime')
|
|
485
|
-
.then(function (constant) { return SCALEInt_1.SCALEInt.decode(constant).decoded.toNumber(); })
|
|
486
|
-
.catch(function () { return 6000; })];
|
|
487
|
-
case 1:
|
|
488
|
-
blockTime = _a.sent();
|
|
489
|
-
this.cache.expirationTime = Math.floor(blockTime / 3);
|
|
490
|
-
return [2 /*return*/];
|
|
148
|
+
const expectedBlockTime = constants[0];
|
|
149
|
+
const epochDuration = constants[1];
|
|
150
|
+
const sessionsPerEra = constants[2];
|
|
151
|
+
return expectedBlockTime.multipliedBy(epochDuration).multipliedBy(sessionsPerEra);
|
|
152
|
+
}
|
|
153
|
+
async getActiveEraInfo() {
|
|
154
|
+
return this.fromStorage('Staking', 'ActiveEra').then((item) => item ? SubstrateActiveEraInfo_1.SubstrateActiveEraInfo.decode(this.network, this.runtimeVersion, item) : null);
|
|
155
|
+
}
|
|
156
|
+
async getSlashingSpan(address) {
|
|
157
|
+
return this.fromStorage('Staking', 'SlashingSpans', SCALEAccountId_1.SCALEAccountId.from(address, this.network)).then((item) => item ? SubstrateSlashingSpans_1.SubstrateSlashingSpans.decode(this.network, this.runtimeVersion, item) : null);
|
|
158
|
+
}
|
|
159
|
+
async submitTransaction(encoded) {
|
|
160
|
+
return this.send('author', 'submitExtrinsic', [encoded], { allowCache: false });
|
|
161
|
+
}
|
|
162
|
+
async getBlockHash(blockNumber) {
|
|
163
|
+
return this.send('chain', 'getBlockHash', blockNumber !== undefined ? [(0, hex_1.toHexString)(blockNumber)] : []);
|
|
164
|
+
}
|
|
165
|
+
async fromStorage(moduleName, entryName, ...args) {
|
|
166
|
+
await this.initApi();
|
|
167
|
+
const storageEntry = this.metadata?.storageEntry(moduleName, entryName);
|
|
168
|
+
if (!storageEntry) {
|
|
169
|
+
console.warn(`Could not find requested item: ${moduleName} ${entryName}`);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const hash = await storageEntry.hash(...args);
|
|
173
|
+
const result = await this.send('state', 'getStorage', [hash]);
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
async getCall(moduleName, callName) {
|
|
177
|
+
await this.initApi();
|
|
178
|
+
const call = this.metadata?.call(moduleName, callName);
|
|
179
|
+
return call ? call : Promise.reject(`Could not find requested item: ${moduleName} ${callName}`);
|
|
180
|
+
}
|
|
181
|
+
async getConstant(moduleName, constantName) {
|
|
182
|
+
await this.initApi();
|
|
183
|
+
const constant = this.metadata?.constant(moduleName, constantName);
|
|
184
|
+
return constant ? constant.value.toString('hex') : Promise.reject(`Could not find requested item: ${moduleName} ${constantName}`);
|
|
185
|
+
}
|
|
186
|
+
async initApi() {
|
|
187
|
+
if (!this.initApiPromise) {
|
|
188
|
+
const initApiPromise = new Promise(async (resolve, reject) => {
|
|
189
|
+
const [metadataEncoded, runtimeVersion] = await Promise.all([this.send('state', 'getMetadata'), this.getRuntimeVersion()]);
|
|
190
|
+
if (!runtimeVersion) {
|
|
191
|
+
reject('Could not fetch runtime version from the node');
|
|
491
192
|
}
|
|
193
|
+
this.metadata = Metadata_1.Metadata.decode(this.network, runtimeVersion?.specVersion, metadataEncoded).decorate(this.storageEntries, this.calls, this.constants);
|
|
194
|
+
this.runtimeVersion = runtimeVersion?.specVersion;
|
|
195
|
+
resolve();
|
|
196
|
+
}).then(async () => {
|
|
197
|
+
this.initApiPromise = Promise.resolve();
|
|
198
|
+
await this.initCache();
|
|
492
199
|
});
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
if (params === void 0) { params = []; }
|
|
497
|
-
if (config === void 0) { config = { allowCache: true }; }
|
|
498
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
499
|
-
var endpoint, key;
|
|
500
|
-
var _this = this;
|
|
501
|
-
return __generator(this, function (_a) {
|
|
502
|
-
endpoint = "".concat(module, "_").concat(method);
|
|
503
|
-
key = "".concat(endpoint, "$").concat(params.join(''));
|
|
504
|
-
return [2 /*return*/, this.cache.get(key).catch(function () {
|
|
505
|
-
var promise = _this.sendRepeat(endpoint, params);
|
|
506
|
-
return _this.cache.save(key, promise, { cacheValue: config.allowCache });
|
|
507
|
-
})];
|
|
508
|
-
});
|
|
509
|
-
});
|
|
510
|
-
};
|
|
511
|
-
SubstrateNodeClient.prototype.sendRepeat = function (endpoint, params, attempts) {
|
|
512
|
-
if (attempts === void 0) { attempts = 0; }
|
|
513
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
514
|
-
var handleResponse, handleAxiosError, handleError;
|
|
515
|
-
var _this = this;
|
|
516
|
-
return __generator(this, function (_a) {
|
|
517
|
-
handleResponse = function (response) {
|
|
518
|
-
var data = response.data;
|
|
519
|
-
if (data.error) {
|
|
520
|
-
throw data.error;
|
|
521
|
-
}
|
|
522
|
-
return data.result;
|
|
523
|
-
};
|
|
524
|
-
handleAxiosError = function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
525
|
-
var _a;
|
|
526
|
-
return __generator(this, function (_b) {
|
|
527
|
-
switch (_b.label) {
|
|
528
|
-
case 0:
|
|
529
|
-
if (!(((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 500 && attempts < MAX_RETRIES)) return [3 /*break*/, 2];
|
|
530
|
-
return [4 /*yield*/, this.sendRepeat(endpoint, params, attempts + 1)];
|
|
531
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
532
|
-
case 2: throw new errors_1.NetworkError(coinlib_error_1.Domain.SUBSTRATE, error);
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
}); };
|
|
536
|
-
handleError = function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
537
|
-
var axiosError;
|
|
538
|
-
return __generator(this, function (_a) {
|
|
539
|
-
switch (_a.label) {
|
|
540
|
-
case 0:
|
|
541
|
-
if (!(typeof error === 'string')) return [3 /*break*/, 1];
|
|
542
|
-
throw new errors_1.NetworkError(coinlib_error_1.Domain.SUBSTRATE, {}, error);
|
|
543
|
-
case 1:
|
|
544
|
-
axiosError = error;
|
|
545
|
-
return [4 /*yield*/, handleAxiosError(axiosError)];
|
|
546
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
}); };
|
|
550
|
-
return [2 /*return*/, axios_0_19_0_1.default
|
|
551
|
-
.post(this.baseURL, new RPCBody_1.RPCBody(endpoint, params.map(hex_1.addHexPrefix)))
|
|
552
|
-
.then(handleResponse)
|
|
553
|
-
.catch(handleError)];
|
|
200
|
+
this.initApiPromise = initApiPromise.catch((error) => {
|
|
201
|
+
console.warn(error);
|
|
202
|
+
this.initApiPromise = initApiPromise; // retry once
|
|
554
203
|
});
|
|
204
|
+
}
|
|
205
|
+
return this.initApiPromise;
|
|
206
|
+
}
|
|
207
|
+
async initCache() {
|
|
208
|
+
const blockTime = await this.getConstant('Babe', 'ExpectedBlockTime')
|
|
209
|
+
.then((constant) => SCALEInt_1.SCALEInt.decode(constant).decoded.toNumber())
|
|
210
|
+
.catch(() => 6000);
|
|
211
|
+
this.cache.expirationTime = Math.floor(blockTime / 3);
|
|
212
|
+
}
|
|
213
|
+
async send(module, method, params = [], config = { allowCache: true }) {
|
|
214
|
+
const endpoint = `${module}_${method}`;
|
|
215
|
+
const key = `${endpoint}$${params.join('')}`;
|
|
216
|
+
return this.cache.get(key).catch(() => {
|
|
217
|
+
const promise = this.sendRepeat(endpoint, params);
|
|
218
|
+
return this.cache.save(key, promise, { cacheValue: config.allowCache });
|
|
555
219
|
});
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
220
|
+
}
|
|
221
|
+
async sendRepeat(endpoint, params, attempts = 0) {
|
|
222
|
+
const handleResponse = (response) => {
|
|
223
|
+
const data = response.data;
|
|
224
|
+
if (data.error) {
|
|
225
|
+
throw data.error;
|
|
226
|
+
}
|
|
227
|
+
return data.result;
|
|
228
|
+
};
|
|
229
|
+
const handleAxiosError = async (error) => {
|
|
230
|
+
if (error.response?.status === 500 && attempts < MAX_RETRIES) {
|
|
231
|
+
return await this.sendRepeat(endpoint, params, attempts + 1);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
throw new errors_1.NetworkError(coinlib_error_1.Domain.SUBSTRATE, error);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
const handleError = async (error) => {
|
|
238
|
+
if (typeof error === 'string') {
|
|
239
|
+
throw new errors_1.NetworkError(coinlib_error_1.Domain.SUBSTRATE, {}, error);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
const axiosError = error;
|
|
243
|
+
return await handleAxiosError(axiosError);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
return axios_0_19_0_1.default
|
|
247
|
+
.post(this.baseURL, new RPCBody_1.RPCBody(endpoint, params.map(hex_1.addHexPrefix)))
|
|
248
|
+
.then(handleResponse)
|
|
249
|
+
.catch(handleError);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
559
252
|
exports.SubstrateNodeClient = SubstrateNodeClient;
|
|
560
253
|
//# sourceMappingURL=SubstrateNodeClient.js.map
|