Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update types #319

Merged
merged 3 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webb-tools/protocol-substrate-types",
"version": "0.0.6",
"version": "0.0.7",
"description": "Polkadot.js type definitions required for interacting with Webb's substrate protocol",
"main": "./build/index.js",
"author": "Webb Developers <drew@webb.tools>",
Expand All @@ -21,7 +21,7 @@
"@babel/runtime": "^7.19.0",
"@open-web3/orml-types": "^1.1.3",
"@polkadot/api-derive": "10.1.4",
"@polkadot/dev": "^0.72.16",
"@polkadot/dev": "^0.72.34",
"@polkadot/typegen": "10.1.4",
"@polkadot/types": "10.1.4",
"fs-extra": "^11.1.1",
Expand All @@ -40,8 +40,8 @@
"scripts": {
"build": "node ./scripts/build.js",
"build:interfaces": "yarn build:interfaces:defs && yarn build:interfaces:chain && rm ./src/interfaces/index.ts && rm ./src/interfaces/types.ts",
"build:interfaces:defs": "npx ts-node node_modules/.bin/polkadot-types-from-defs --input ./src/interfaces --package @webb-tools/protocol-substrate-types --endpoint ./src/metadata/metadata.json",
"build:interfaces:chain": "npx ts-node node_modules/.bin/polkadot-types-from-chain --endpoint ws://localhost:9944 --output ./src/interfaces",
"build:interfaces:defs": "npx ts-node node_modules/.bin/polkadot-types-from-defs --input ./src/interfaces --endpoint ./src/metadata/metadata.json --package @webb-tools/protocol-substrate-types",
"build:interfaces:chain": "npx ts-node node_modules/.bin/polkadot-types-from-chain --output ./src/interfaces --endpoint ./src/metadata/metadata.json",
"clean": "rm -rf build && rm -rf ts-types",
"publish-types": "node ./scripts/publish-types.js",
"update:metadata": "npx ts-node ./scripts/updateMetadata.ts"
Expand Down
31 changes: 2 additions & 29 deletions types/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,15 @@ function copyMiscFiles(dir) {
fs.writeFileSync('./build/package.json', newPkgString);
}

// @param module - the module system to use cjs or esm.
async function buildBabel(dir, module = 'esm') {
console.log('build babel for: ', module);

// babel configuratiom
const configFileName = `babel-config-cjs.cjs`;

// Prefer to use local config over the root one.
const conf = path.join(process.cwd(), configFileName);

// Commonjs builds will exist in a '/cjs' directory for the package.
await babel({
babelOptions: {
configFile: conf
},
cliOptions: {
extensions: ['.ts'],
filenames: ['src'],
ignore: '**/*.d.ts',
outDir: path.join(process.cwd(), 'build'),
outFileExtension: '.js'
}
});

copyMiscFiles(dir, module);
}

async function buildJs(dir) {
if (!fs.existsSync(path.join(process.cwd(), '.skip-build'))) {
const { name, version } = require(path.join(process.cwd(), './package.json'));

console.log(`*** ${name} ${version}`);

mkdirp.sync('build');

await buildBabel(dir, 'cjs');
copyMiscFiles();
}
}

Expand Down
40 changes: 24 additions & 16 deletions types/src/interfaces/augment-api-consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { ApiTypes, AugmentedConst } from '@polkadot/api-base/types';
import type { Option, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
import type { Codec } from '@polkadot/types-codec/types';
import type { Perbill, Permill } from '@polkadot/types/interfaces/runtime';
import { SpWeightsWeightV2Weight, FrameSupportPalletId, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, SpWeightsRuntimeDbWeight, SpVersionRuntimeVersion } from '@polkadot/types/lookup';

export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>;

Expand Down Expand Up @@ -62,18 +63,6 @@ declare module '@polkadot/api-base/types/consts' {
**/
[key: string]: Codec;
};
authorship: {
/**
* The number of blocks back we should accept uncles.
* This means that we will deal with uncle-parents that are
* `UncleGenerations + 1` before `now`.
**/
uncleGenerations: u64 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
babe: {
/**
* The amount of time, in slots, that each epoch should last.
Expand Down Expand Up @@ -412,18 +401,28 @@ declare module '@polkadot/api-base/types/consts' {
/**
* The maximum number of candidates in a phragmen election.
*
* Warning: The election happens onchain, and this value will determine
* the size of the election. When this limit is reached no more
* candidates are accepted in the election.
* Warning: This impacts the size of the election which is run onchain. Chose wisely, and
* consider how it will impact `T::WeightInfo::election_phragmen`.
*
* When this limit is reached no more candidates are accepted in the election.
**/
maxCandidates: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of voters to allow in a phragmen election.
*
* Warning: This impacts the size of the election which is run onchain.
* Warning: This impacts the size of the election which is run onchain. Chose wisely, and
* consider how it will impact `T::WeightInfo::election_phragmen`.
*
* When the limit is reached the new voters are ignored.
**/
maxVoters: u32 & AugmentedConst<ApiType>;
/**
* Maximum numbers of votes per voter.
*
* Warning: This impacts the size of the election which is run onchain. Chose wisely, and
* consider how it will impact `T::WeightInfo::election_phragmen`.
**/
maxVotesPerVoter: u32 & AugmentedConst<ApiType>;
/**
* Identifier for the elections-phragmen pallet's lock
**/
Expand Down Expand Up @@ -455,6 +454,15 @@ declare module '@polkadot/api-base/types/consts' {
* Max Authorities in use
**/
maxAuthorities: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of entries to keep in the set id to session index mapping.
*
* Since the `SetIdSession` map is only used for validating equivocations this
* value should relate to the bonding duration of whatever staking system is
* being used (if any). If equivocation handling is not enabled then this value
* can be zero.
**/
maxSetIdSessionEntries: u64 & AugmentedConst<ApiType>;
/**
* Generic const
**/
Expand Down
42 changes: 8 additions & 34 deletions types/src/interfaces/augment-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,40 +139,6 @@ declare module '@polkadot/api-base/types/errors' {
**/
[key: string]: AugmentedError<ApiType>;
};
authorship: {
/**
* The uncle is genesis.
**/
GenesisUncle: AugmentedError<ApiType>;
/**
* The uncle parent not in the chain.
**/
InvalidUncleParent: AugmentedError<ApiType>;
/**
* The uncle isn't recent enough to be included.
**/
OldUncle: AugmentedError<ApiType>;
/**
* The uncle is too high in chain.
**/
TooHighUncle: AugmentedError<ApiType>;
/**
* Too many uncles.
**/
TooManyUncles: AugmentedError<ApiType>;
/**
* The uncle is already included.
**/
UncleAlreadyIncluded: AugmentedError<ApiType>;
/**
* Uncles already set in the block.
**/
UnclesAlreadySet: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
babe: {
/**
* A given equivocation report is valid but already previously reported.
Expand Down Expand Up @@ -437,6 +403,10 @@ declare module '@polkadot/api-base/types/errors' {
* The given account did not vote on the referendum.
**/
NotVoter: AugmentedError<ApiType>;
/**
* The preimage does not exist.
**/
PreimageNotExist: AugmentedError<ApiType>;
/**
* Proposal still blacklisted
**/
Expand Down Expand Up @@ -885,6 +855,10 @@ declare module '@polkadot/api-base/types/errors' {
* pool at a time.
**/
AccountBelongsToOtherPool: AugmentedError<ApiType>;
/**
* Bonding extra is restricted to the exact pending reward amount.
**/
BondExtraRestricted: AugmentedError<ApiType>;
/**
* The pools state cannot be changed.
**/
Expand Down
56 changes: 41 additions & 15 deletions types/src/interfaces/augment-api-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { ApiTypes, AugmentedEvent } from '@polkadot/api-base/types';
import type { Bytes, Null, Option, Result, U8aFixed, Vec, bool, i128, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, H256, Perbill } from '@polkadot/types/interfaces/runtime';
import { PalletAssetRegistryAssetType, FrameSupportTokensMiscBalanceStatus, SpRuntimeDispatchError, PalletDemocracyMetadataOwner, PalletDemocracyVoteThreshold, PalletDemocracyVoteAccountVote, PalletElectionProviderMultiPhaseElectionCompute, SpNposElectionsElectionScore, PalletElectionProviderMultiPhasePhase, SpFinalityGrandpaAppPublic, PalletImOnlineSr25519AppSr25519Public, PalletStakingExposure, WebbPrimitivesRuntimeElement, PalletMultisigTimepoint, PalletNominationPoolsPoolState, WebbStandaloneRuntimeProxyType, PalletStakingForcing, PalletStakingValidatorPrefs, FrameSupportDispatchDispatchInfo } from '@polkadot/types/lookup';

export type __AugmentedEvent<ApiType extends ApiTypes> = AugmentedEvent<ApiType>;

Expand Down Expand Up @@ -92,7 +93,7 @@ declare module '@polkadot/api-base/types/events' {
/**
* Some assets were issued.
**/
Issued: AugmentedEvent<ApiType, [assetId: u32, owner: AccountId32, totalSupply: u128], { assetId: u32, owner: AccountId32, totalSupply: u128 }>;
Issued: AugmentedEvent<ApiType, [assetId: u32, owner: AccountId32, amount: u128], { assetId: u32, owner: AccountId32, amount: u128 }>;
/**
* Metadata has been cleared for an asset.
**/
Expand Down Expand Up @@ -309,6 +310,18 @@ declare module '@polkadot/api-base/types/events' {
* An external proposal has been tabled.
**/
ExternalTabled: AugmentedEvent<ApiType, []>;
/**
* Metadata for a proposal or a referendum has been cleared.
**/
MetadataCleared: AugmentedEvent<ApiType, [owner: PalletDemocracyMetadataOwner, hash_: H256], { owner: PalletDemocracyMetadataOwner, hash_: H256 }>;
/**
* Metadata for a proposal or a referendum has been set.
**/
MetadataSet: AugmentedEvent<ApiType, [owner: PalletDemocracyMetadataOwner, hash_: H256], { owner: PalletDemocracyMetadataOwner, hash_: H256 }>;
/**
* Metadata has been transferred to new owner.
**/
MetadataTransferred: AugmentedEvent<ApiType, [prevOwner: PalletDemocracyMetadataOwner, owner: PalletDemocracyMetadataOwner, hash_: H256], { prevOwner: PalletDemocracyMetadataOwner, owner: PalletDemocracyMetadataOwner, hash_: H256 }>;
/**
* A proposal has been rejected by referendum.
**/
Expand Down Expand Up @@ -366,30 +379,27 @@ declare module '@polkadot/api-base/types/events' {
**/
ElectionFinalized: AugmentedEvent<ApiType, [compute: PalletElectionProviderMultiPhaseElectionCompute, score: SpNposElectionsElectionScore], { compute: PalletElectionProviderMultiPhaseElectionCompute, score: SpNposElectionsElectionScore }>;
/**
* An account has been rewarded for their signed submission being finalized.
* There was a phase transition in a given round.
**/
Rewarded: AugmentedEvent<ApiType, [account: AccountId32, value: u128], { account: AccountId32, value: u128 }>;
PhaseTransitioned: AugmentedEvent<ApiType, [from: PalletElectionProviderMultiPhasePhase, to: PalletElectionProviderMultiPhasePhase, round: u32], { from: PalletElectionProviderMultiPhasePhase, to: PalletElectionProviderMultiPhasePhase, round: u32 }>;
/**
* The signed phase of the given round has started.
* An account has been rewarded for their signed submission being finalized.
**/
SignedPhaseStarted: AugmentedEvent<ApiType, [round: u32], { round: u32 }>;
Rewarded: AugmentedEvent<ApiType, [account: AccountId32, value: u128], { account: AccountId32, value: u128 }>;
/**
* An account has been slashed for submitting an invalid signed submission.
**/
Slashed: AugmentedEvent<ApiType, [account: AccountId32, value: u128], { account: AccountId32, value: u128 }>;
/**
* A solution was stored with the given compute.
*
* If the solution is signed, this means that it hasn't yet been processed. If the
* solution is unsigned, this means that it has also been processed.
*
* The `bool` is `true` when a previous solution was ejected to make room for this one.
* The `origin` indicates the origin of the solution. If `origin` is `Some(AccountId)`,
* the stored solution was submited in the signed phase by a miner with the `AccountId`.
* Otherwise, the solution was stored either during the unsigned phase or by
* `T::ForceOrigin`. The `bool` is `true` when a previous solution was ejected to make
* room for this one.
**/
SolutionStored: AugmentedEvent<ApiType, [compute: PalletElectionProviderMultiPhaseElectionCompute, prevEjected: bool], { compute: PalletElectionProviderMultiPhaseElectionCompute, prevEjected: bool }>;
/**
* The unsigned phase of the given round has started.
**/
UnsignedPhaseStarted: AugmentedEvent<ApiType, [round: u32], { round: u32 }>;
SolutionStored: AugmentedEvent<ApiType, [compute: PalletElectionProviderMultiPhaseElectionCompute, origin: Option<AccountId32>, prevEjected: bool], { compute: PalletElectionProviderMultiPhaseElectionCompute, origin: Option<AccountId32>, prevEjected: bool }>;
/**
* Generic event
**/
Expand Down Expand Up @@ -603,7 +613,7 @@ declare module '@polkadot/api-base/types/events' {
* The roles of a pool have been updated to the given new roles. Note that the depositor
* can never change.
**/
RolesUpdated: AugmentedEvent<ApiType, [root: Option<AccountId32>, stateToggler: Option<AccountId32>, nominator: Option<AccountId32>], { root: Option<AccountId32>, stateToggler: Option<AccountId32>, nominator: Option<AccountId32> }>;
RolesUpdated: AugmentedEvent<ApiType, [root: Option<AccountId32>, bouncer: Option<AccountId32>, nominator: Option<AccountId32>], { root: Option<AccountId32>, bouncer: Option<AccountId32>, nominator: Option<AccountId32> }>;
/**
* The state of a pool has changed
**/
Expand Down Expand Up @@ -795,6 +805,10 @@ declare module '@polkadot/api-base/types/events' {
* the remainder from the maximum amount of reward.
**/
EraPaid: AugmentedEvent<ApiType, [eraIndex: u32, validatorPayout: u128, remainder: u128], { eraIndex: u32, validatorPayout: u128, remainder: u128 }>;
/**
* A new force era mode was set.
**/
ForceEra: AugmentedEvent<ApiType, [mode: PalletStakingForcing], { mode: PalletStakingForcing }>;
/**
* A nominator has been kicked from a validator.
**/
Expand Down Expand Up @@ -913,6 +927,10 @@ declare module '@polkadot/api-base/types/events' {
* An account was created with some free balance.
**/
Endowed: AugmentedEvent<ApiType, [currencyId: u32, who: AccountId32, amount: u128], { currencyId: u32, who: AccountId32, amount: u128 }>;
/**
* Some free balance was locked.
**/
Locked: AugmentedEvent<ApiType, [currencyId: u32, who: AccountId32, amount: u128], { currencyId: u32, who: AccountId32, amount: u128 }>;
/**
* Some locked funds were unlocked
**/
Expand Down Expand Up @@ -942,6 +960,10 @@ declare module '@polkadot/api-base/types/events' {
* Transfer succeeded.
**/
Transfer: AugmentedEvent<ApiType, [currencyId: u32, from: AccountId32, to: AccountId32, amount: u128], { currencyId: u32, from: AccountId32, to: AccountId32, amount: u128 }>;
/**
* Some locked balance was freed.
**/
Unlocked: AugmentedEvent<ApiType, [currencyId: u32, who: AccountId32, amount: u128], { currencyId: u32, who: AccountId32, amount: u128 }>;
/**
* Some balance was unreserved (moved from reserved to free).
**/
Expand Down Expand Up @@ -1017,6 +1039,10 @@ declare module '@polkadot/api-base/types/events' {
* We have ended a spend period and will now allocate funds.
**/
Spending: AugmentedEvent<ApiType, [budgetRemaining: u128], { budgetRemaining: u128 }>;
/**
* The inactive funds of the pallet have been updated.
**/
UpdatedInactive: AugmentedEvent<ApiType, [reactivated: u128, deactivated: u128], { reactivated: u128, deactivated: u128 }>;
/**
* Generic event
**/
Expand Down
Loading