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

feat(types): migrate types.json in /node/build.rs #198

Closed
wants to merge 4 commits into from
Closed
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
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 2 additions & 87 deletions js/pint-types-bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,99 +2,14 @@ import {
OverrideBundleDefinition,
OverrideBundleType,
} from "@polkadot/types/types";
import PINTTypes from "./pint.json";

export const definitions = {
types: [
{
// on all versions
minmax: [0, undefined],
types: {
Address: "MultiAddress",
LookupSource: "MultiAddress",
LookupSourceFor: "LookupSource",
Action: "Call",
AssetId: "u32",
AccountIdFor: "AccountId",
AccountBalance: {
available: "Balance",
reserved: "Balance",
},
AssetAvailability: {
_enum: {
Liquid: "MultiLocation",
Saft: null,
},
},
AssetWithdrawal: {
asset: "AssetId",
state: "RedemptionState",
units: "Balance",
},
Balance: "u128",
BalanceFor: "Balance",
CommitteeMember: {
account_id: "AccountId",
member_type: "MemberType",
},
CurrencyId: "AssetId",
CurrencyIdOf: "CurrencyId",
FeedId: "u64",
FeedIdFor: "FeedId",
HashFor: "Hash",
IndexAssetData: {
units: "Balance",
availability: "AssetAvailability",
},
MemberType: {
_enum: {
Council: null,
Constituent: null,
},
},
MemberVote: {
member: "CommitteeMember",
vote: "Vote",
},
PendingRedemption: {
initiated: "BlockNumber",
assets: "Vec<AssetWithdrawal>",
},
ProposalNonce: "u32",
ProxyType: {
_enum: ["Any", "NonTransfer", "Governance", "Staking"],
},
ProxyState: {
added: "Vec<ProxyType>",
},
RedemptionState: {
_enum: {
Initiated: null,
Unbonding: null,
Transferred: null,
},
},
SAFTRecord: {
nav: "Balance",
units: "Balance",
},
StakingBondState: {
controller: "LookupSourceFor",
bonded: "Balance",
unbonded: "Balance",
unlocked_chunks: "u32",
},
Vote: {
_enum: {
Aye: null,
Nay: null,
Abstain: null,
},
},
VoteAggregate: {
votes: "Vec<MemberVote>",
end: "BlockNumber",
},
},
types: PINTTypes,
},
],
} as OverrideBundleDefinition;
Expand Down
152 changes: 152 additions & 0 deletions js/pint-types-bundle/pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"Address": "MultiAddress",
"LookupSource": "MultiAddress",
"LookupSourceFor": "LookupSource",
"Action": "Call",
"AssetId": "u32",
"AccountIdFor": "AccountId",
"AccountBalance": {
"available": "Balance",
"reserved": "Balance"
},
"AssetAvailability": {
"_enum": {
"Liquid": "MultiLocation",
"Saft": null
}
},
"AssetWithdrawal": {
"asset": "AssetId",
"state": "RedemptionState",
"units": "Balance"
},
"Balance": "u128",
"BalanceFor": "Balance",
"CommitteeMember": {
"account_id": "AccountId",
"member_type": "MemberType"
},
"CurrencyId": "AssetId",
"CurrencyIdOf": "CurrencyId",
"HashFor": "Hash",
"IndexAssetData": {
"units": "Balance",
"availability": "AssetAvailability"
},
"MemberType": {
"_enum": {
"Council": null,
"Constituent": null
}
},
"MemberVote": {
"member": "CommitteeMember",
"vote": "Vote"
},
"PendingRedemption": {
"initiated": "BlockNumber",
"assets": "Vec<AssetWithdrawal>"
},
"ProposalNonce": "u32",
"ProxyType": {
"_enum": ["Any", "NonTransfer", "Governance", "Staking"]
},
"ProxyState": {
"added": "Vec<ProxyType>"
},
"RedemptionState": {
"_enum": {
"Initiated": null,
"Unbonding": null,
"Transferred": null
}
},
"SAFTRecord": {
"nav": "Balance",
"units": "Balance"
},
"StakingBondState": {
"controller": "LookupSourceFor",
"bonded": "Balance",
"unbonded": "Balance",
"unlocked_chunks": "u32"
},
"Vote": {
"_enum": {
"Aye": null,
"Nay": null,
"Abstain": null
}
},
"VoteAggregate": {
"votes": "Vec<MemberVote>",
"end": "BlockNumber"
},
"SpecIndex": "Vec<u8>",
"RequestIdentifier": "u64",
"DataVersion": "u64",
"FeedId": "u64",
"FeedIdFor": "FeedId",
"RoundId": "u32",
"Value": "u128",
"FeedConfig": {
"owner": "AccountId",
"pending_owner": "Option<AccountId>",
"submission_value_bounds": "(Value, Value)",
"submission_count_bounds": "(u32, u32)",
"payment": "Balance",
"timeout": "BlockNumber",
"decimals": "u8",
"description": "Vec<u8>",
"restart_delay": "RoundId",
"reporting_round": "RoundId",
"latest_round": "RoundId",
"first_valid_round": "Option<RoundId>",
"oracle_count": "u32",
"pruning_window": "RoundId",
"next_round_to_prune": "RoundId",
"debt": "Balance",
"max_debt": "Option<Balance>"
},
"FeedConfigOf": "FeedConfig",
"Round": {
"started_at": "BlockNumber",
"answer": "Option<Value>",
"updated_at": "Option<BlockNumber>",
"answered_in_round": "Option<RoundId>"
},
"RoundOf": "Round",
"RoundDetails": {
"submissions": "Vec<Value>",
"submission_count_bounds": "(u32, u32)",
"payment": "Balance",
"timeout": "BlockNumber"
},
"RoundDetailsOf": "RoundDetails",
"OracleMeta": {
"withdrawable": "Balance",
"admin": "AccountId",
"pending_admin": "Option<AccountId>"
},
"OracleMetaOf": "OracleMeta",
"OracleStatus": {
"starting_round": "RoundId",
"ending_round": "Option<RoundId>",
"last_reported_round": "Option<RoundId>",
"last_started_round": "Option<RoundId>",
"latest_submission": "Option<Value>"
},
"OracleStatusOf": "OracleStatus",
"Requester": {
"delay": "RoundId",
"last_started_round": "Option<RoundId>"
},
"RoundData": {
"started_at": "BlockNumber",
"answer": "Value",
"updated_at": "BlockNumber",
"answered_in_round": "RoundId"
},
"RoundDataOf": "RoundData",
"SubmissionBounds": "(u32, u32)"
}
7 changes: 7 additions & 0 deletions node/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
// Copyright 2021 ChainSafe Systems
// SPDX-License-Identifier: LGPL-3.0-only
use std::fs;

const PINT_TYPES_SOURCE: &'static str = "../js/pint-types-bundle/pint.json";
const PINT_TYPES_TARGET: &'static str = "../resources/types.json";

use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

fn main() {
generate_cargo_keys();
rerun_if_git_head_changed();

// Generate PINT types
fs::copy(PINT_TYPES_SOURCE, PINT_TYPES_TARGET).expect("Generate PINT types failed");
Comment on lines +13 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should put anything in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build.rs in / doesn't work, otherwise, we write the script in CI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, we should really keep it separate here and rather put it in CI

}