From fb669116bf60e8e4fb0433cd79b7c1518c2c18d0 Mon Sep 17 00:00:00 2001 From: Tlalocman Date: Thu, 21 Sep 2023 18:23:29 -0600 Subject: [PATCH] Update pallets to external repo (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🔧 chore(Cargo.toml): update dependencies to use specific tags for pallets 🔧 chore(lib.rs): add pallet_mapped_assets and pallet_afloat to the runtime configuration 🔧 chore(lib.rs): update configuration parameters for pallet_gated_marketplace, pallet_confidential_docs, pallet_rbac, pallet_afloat, and pallet_fund_admin_records * 🔧 chore(lib.rs): refactor pallet_mapped_assets configuration for improved readability and maintainability 🔧 chore(lib.rs): refactor pallet_rbac configuration for improved readability and maintainability * 📦 chore(gpt-commit-summarizer.yml): add GitHub Actions workflow file for GPT Commits summarizer 🔒 chore(gpt-commit-summarizer.yml): add necessary permissions to the workflow for repositories that require it 🔧 chore(gpt-commit-summarizer.yml): configure the workflow to trigger on pull request opened and synchronized events 🚀 chore(gpt-commit-summarizer.yml): add job to summarize commits and generate file and PR summaries 🔑 chore(gpt-commit-summarizer.yml): add environment variables for GitHub token and OpenAI API key * 🔧 chore(chain_spec.rs): add default value for mapped_assets field in testnet_genesis function to prevent potential runtime errors --- .github/workflows/gpt-commit-summarizer.yml | 17 +++ Cargo.lock | 83 ++++++++++- node/src/chain_spec.rs | 1 + runtime/Cargo.toml | 21 ++- runtime/src/lib.rs | 148 ++++++++++++++------ 5 files changed, 213 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/gpt-commit-summarizer.yml diff --git a/.github/workflows/gpt-commit-summarizer.yml b/.github/workflows/gpt-commit-summarizer.yml new file mode 100644 index 0000000..e2d910e --- /dev/null +++ b/.github/workflows/gpt-commit-summarizer.yml @@ -0,0 +1,17 @@ +name: GPT Commits summarizer +# Summary: This action will write a comment about every commit in a pull request, as well as generate a summary for every file that was modified and add it to the review page, compile a PR summary from all commit summaries and file diff summaries, and delete outdated code review comments + +on: + pull_request: + types: [opened, synchronize] + +jobs: + summarize: + runs-on: ubuntu-latest + permissions: write-all # Some repositories need this line + + steps: + - uses: KanHarI/gpt-commit-summarizer@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} diff --git a/Cargo.lock b/Cargo.lock index d8420f9..45e24bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2634,6 +2634,7 @@ dependencies = [ "frame-try-runtime", "hex-literal", "log", + "pallet-afloat", "pallet-assets", "pallet-aura", "pallet-balances", @@ -2643,18 +2644,20 @@ dependencies = [ "pallet-confidential-docs", "pallet-fruniques", "pallet-fund-admin", + "pallet-fund-admin-records", "pallet-gated-marketplace", "pallet-grandpa", "pallet-identity", "pallet-indices", "pallet-insecure-randomness-collective-flip", + "pallet-mapped-assets", "pallet-membership", "pallet-node-authorization", "pallet-rbac", "pallet-recovery", "pallet-society", "pallet-sudo", - "pallet-template", + "pallet-template 4.0.0-dev", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", @@ -4568,6 +4571,28 @@ dependencies = [ "libm 0.1.4", ] +[[package]] +name = "pallet-afloat" +version = "4.0.0-dev" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-fruniques", + "pallet-gated-marketplace", + "pallet-mapped-assets", + "pallet-rbac", + "pallet-timestamp", + "pallet-uniques", + "parity-scale-codec", + "scale-info", + "serde", + "sp-runtime", +] + [[package]] name = "pallet-assets" version = "4.0.0-dev" @@ -4631,7 +4656,7 @@ dependencies = [ [[package]] name = "pallet-bitcoin-vaults" version = "4.0.0-dev" -source = "git+https://github.com/hashed-io/hashed-pallets?branch=bump-versions/substrate-940#1fdc53df2b035beff45a2c6dfe8cf99cb7755049" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" dependencies = [ "frame-benchmarking", "frame-support", @@ -4686,7 +4711,7 @@ dependencies = [ [[package]] name = "pallet-confidential-docs" version = "4.0.0-dev" -source = "git+https://github.com/hashed-io/hashed-pallets?branch=bump-versions/substrate-940#1fdc53df2b035beff45a2c6dfe8cf99cb7755049" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" dependencies = [ "frame-benchmarking", "frame-support", @@ -4698,7 +4723,7 @@ dependencies = [ [[package]] name = "pallet-fruniques" version = "0.1.0-dev" -source = "git+https://github.com/hashed-io/hashed-pallets?branch=bump-versions/substrate-940#1fdc53df2b035beff45a2c6dfe8cf99cb7755049" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" dependencies = [ "frame-benchmarking", "frame-support", @@ -4715,7 +4740,7 @@ dependencies = [ [[package]] name = "pallet-fund-admin" version = "4.0.0-dev" -source = "git+https://github.com/hashed-io/hashed-pallets?branch=bump-versions/substrate-940#1fdc53df2b035beff45a2c6dfe8cf99cb7755049" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" dependencies = [ "frame-benchmarking", "frame-support", @@ -4729,10 +4754,24 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-fund-admin-records" +version = "4.0.0-dev" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" +dependencies = [ + "frame-support", + "frame-system", + "log", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-runtime", +] + [[package]] name = "pallet-gated-marketplace" version = "4.0.0-dev" -source = "git+https://github.com/hashed-io/hashed-pallets?branch=bump-versions/substrate-940#1fdc53df2b035beff45a2c6dfe8cf99cb7755049" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" dependencies = [ "frame-benchmarking", "frame-support", @@ -4740,6 +4779,7 @@ dependencies = [ "log", "pallet-balances", "pallet-fruniques", + "pallet-mapped-assets", "pallet-rbac", "pallet-timestamp", "pallet-uniques", @@ -4819,6 +4859,21 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-mapped-assets" +version = "4.0.0-dev" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-rbac", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-membership" version = "4.0.0-dev" @@ -4855,7 +4910,7 @@ dependencies = [ [[package]] name = "pallet-rbac" version = "4.0.0-dev" -source = "git+https://github.com/hashed-io/hashed-pallets?branch=bump-versions/substrate-940#1fdc53df2b035beff45a2c6dfe8cf99cb7755049" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" dependencies = [ "frame-benchmarking", "frame-support", @@ -4945,6 +5000,20 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-template" +version = "4.0.0-dev" +source = "git+https://github.com/hashed-io/hashed-pallets?tag=0.1.1#a8d1072fd5f9da83ce5f37737c25ccd77023b228" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-std", +] + [[package]] name = "pallet-timestamp" version = "4.0.0-dev" diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 43bc890..6fd37da 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -283,5 +283,6 @@ fn testnet_genesis( bitcoin_vaults : BitcoinVaultsConfig{ bdk_services_url : BDK_SERVICES_MAINNET_URL.as_bytes().to_vec(), }, + mapped_assets: Default::default(), } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 0931598..bc82b80 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -64,13 +64,16 @@ frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", b hex-literal = { version = "0.4.1", optional = true } # Hashed Dependencies -pallet-template = { path = "../pallets/template", default-features = false } -pallet-bitcoin-vaults = { git = "https://github.com/hashed-io/hashed-pallets", branch = "bump-versions/substrate-940", default-features = false } -pallet-fruniques = { git = "https://github.com/hashed-io/hashed-pallets", branch = "bump-versions/substrate-940", default-features = false } -pallet-gated-marketplace = { git = "https://github.com/hashed-io/hashed-pallets", branch = "bump-versions/substrate-940", default-features = false } -pallet-rbac = { git = "https://github.com/hashed-io/hashed-pallets", branch = "bump-versions/substrate-940", default-features = false } -pallet-confidential-docs = { git = "https://github.com/hashed-io/hashed-pallets", branch = "bump-versions/substrate-940", default-features = false } -pallet-fund-admin = { git = "https://github.com/hashed-io/hashed-pallets", branch = "bump-versions/substrate-940", default-features = false } +pallet-template = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-fruniques = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-bitcoin-vaults = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-gated-marketplace = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-rbac = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-confidential-docs = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-fund-admin = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-afloat = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-mapped-assets = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } +pallet-fund-admin-records = { git = "https://github.com/hashed-io/hashed-pallets", tag = "0.1.1", default-features = false } [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } @@ -112,6 +115,8 @@ std = [ "pallet-rbac/std", "pallet-confidential-docs/std", "pallet-fund-admin/std", + "pallet-mapped-assets/std", + "pallet-afloat/std", "sp-api/std", "sp-block-builder/std", "sp-consensus-aura/std", @@ -167,4 +172,6 @@ try-runtime = [ "pallet-gated-marketplace/try-runtime", "pallet-rbac/try-runtime", "pallet-template/try-runtime", + "pallet-mapped-assets/try-runtime", + "pallet-afloat/try-runtime", ] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index f3895cc..e96c220 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -26,6 +26,7 @@ use sp_version::RuntimeVersion; pub mod constants; use constants::*; use frame_system::{EnsureRoot, EnsureSigned}; +use pallet_mapped_assets::DefaultCallback; // A few exports that help ease life for downstream crates. pub use frame_support::{ @@ -636,36 +637,37 @@ impl pallet_fund_admin::Config for Runtime { } parameter_types! { - pub const LabelMaxLen:u32 = 32; - pub const MaxAuthsPerMarket:u32 = 3; // 1 of each role (1 owner, 1 admin, etc.) - pub const MaxRolesPerAuth: u32 = 2; - pub const MaxApplicants: u32 = 10; - pub const MaxBlockedUsersPerMarket: u32 = 100; - pub const NotesMaxLen: u32 = 256; - pub const MaxFeedbackLen: u32 = 256; - pub const NameMaxLen: u32 = 100; - pub const MaxFiles: u32 = 10; - pub const MaxApplicationsPerCustodian: u32 = 10; - pub const MaxMarketsPerItem: u32 = 10; - pub const MaxOffersPerMarket: u32 = 100; + pub const LabelMaxLen: u32 = 32; + pub const MaxAuthsPerMarket: u32 = 30; + pub const MaxRolesPerAuth : u32 = 1; + pub const MaxApplicants: u32 = 3; + pub const MaxBlockedUsersPerMarket: u32 = 100; + pub const NotesMaxLen: u32 = 256; + pub const MaxFeedbackLen: u32 = 256; + pub const NameMaxLen: u32 = 100; + pub const MaxFiles: u32 = 10; + pub const MaxApplicationsPerCustodian: u32 = 2; + pub const MaxMarketsPerItem: u32 = 10; + pub const MaxOffersPerMarket: u32 = 100; } impl pallet_gated_marketplace::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MaxAuthsPerMarket = MaxAuthsPerMarket; - type MaxRolesPerAuth = MaxRolesPerAuth; - type MaxApplicants = MaxApplicants; - type MaxBlockedUsersPerMarket = MaxBlockedUsersPerMarket; - type LabelMaxLen = LabelMaxLen; - type NotesMaxLen = NotesMaxLen; - type MaxFeedbackLen = MaxFeedbackLen; - type NameMaxLen = NameMaxLen; - type MaxFiles = MaxFiles; - type MaxApplicationsPerCustodian = MaxApplicationsPerCustodian; - type MaxMarketsPerItem = MaxMarketsPerItem; - type MaxOffersPerMarket = MaxOffersPerMarket; - type Timestamp = Timestamp; - type Moment = Moment; - type Rbac = RBAC; + type RuntimeEvent = RuntimeEvent; + type MaxAuthsPerMarket = MaxAuthsPerMarket; + type MaxRolesPerAuth = MaxRolesPerAuth; + type MaxApplicants = MaxApplicants; + type MaxBlockedUsersPerMarket = MaxBlockedUsersPerMarket; + type LabelMaxLen = LabelMaxLen; + type NotesMaxLen = NotesMaxLen; + type MaxFeedbackLen = MaxFeedbackLen; + type NameMaxLen = NameMaxLen; + type MaxFiles = MaxFiles; + type MaxApplicationsPerCustodian = MaxApplicationsPerCustodian; + type MaxOffersPerMarket = MaxOffersPerMarket; + type MaxMarketsPerItem = MaxMarketsPerItem; + type Timestamp = Timestamp; + type Moment = u64; + //type LocalCurrency = Balances; + type Rbac = RBAC; } parameter_types! { pub const XPubLen: u32 = XPUB_LEN; @@ -725,23 +727,80 @@ impl pallet_confidential_docs::Config for Runtime { } parameter_types! { - pub const MaxScopesPerPallet: u32 = 1000; - pub const MaxRolesPerPallet: u32 = 50; - pub const RoleMaxLen: u32 = 50; - pub const PermissionMaxLen: u32 = 50; - pub const MaxPermissionsPerRole: u32 = 100; - pub const MaxRolesPerUser: u32 = 10; - pub const MaxUsersPerRole: u32 = 2500; + pub const MaxReserves: u32 = 200; +} + +impl pallet_mapped_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = u128; + type AssetId = u32; + type Currency = Balances; + type CreateOrigin = AsEnsureOriginWithArg>; + type ForceOrigin = EnsureRoot; + type AssetDeposit = AssetDeposit; + type AssetAccountDeposit = ConstU128; + type MetadataDepositBase = MetadataDepositBase; + type MetadataDepositPerByte = MetadataDepositPerByte; + type ApprovalDeposit = ApprovalDeposit; + type StringLimit = StringLimit; + type Freezer = (); + type Extra = (); + type WeightInfo = (); + type MaxReserves = MaxReserves; + type ReserveIdentifier = u32; + type RemoveItemsLimit = RemoveItemsLimit; + type AssetIdParameter = u32; + type CallbackHandle = DefaultCallback; + type Rbac = RBAC; +} + +parameter_types! { + pub const MaxScopesPerPallet: u32 = 1000; + pub const MaxRolesPerPallet: u32 = 50; + pub const RoleMaxLen: u32 = 50; + pub const PermissionMaxLen: u32 = 50; + pub const MaxPermissionsPerRole: u32 = 100; + pub const MaxRolesPerUser: u32 = 10; + pub const MaxUsersPerRole: u32 = 2500; } + impl pallet_rbac::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MaxScopesPerPallet = MaxScopesPerPallet; - type MaxRolesPerPallet = MaxRolesPerPallet; - type RoleMaxLen = RoleMaxLen; - type PermissionMaxLen = PermissionMaxLen; - type MaxPermissionsPerRole = MaxPermissionsPerRole; - type MaxRolesPerUser = MaxRolesPerUser; - type MaxUsersPerRole = MaxUsersPerRole; + type RuntimeEvent = RuntimeEvent; + type RemoveOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; + type MaxScopesPerPallet = MaxScopesPerPallet; + type MaxRolesPerPallet = MaxRolesPerPallet; + type RoleMaxLen = RoleMaxLen; + type PermissionMaxLen = PermissionMaxLen; + type MaxPermissionsPerRole = MaxPermissionsPerRole; + type MaxRolesPerUser = MaxRolesPerUser; + type MaxUsersPerRole = MaxUsersPerRole; +} + +impl pallet_afloat::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type TimeProvider = Timestamp; + //type RemoveOrigin = EnsureRoot; + type Rbac = RBAC; + type ItemId = u32; +} + +parameter_types! { + pub const MaxRecordsAtTime:u32 = 50; +} + +impl pallet_fund_admin_records::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RemoveOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; + type Timestamp = Timestamp; + type Moment = u64; + type MaxRecordsAtTime = MaxRecordsAtTime; } parameter_types! { @@ -839,6 +898,9 @@ construct_runtime!( RBAC: pallet_rbac, ConfidentialDocs: pallet_confidential_docs, FundAdmin: pallet_fund_admin, + Afloat: pallet_afloat, + MappedAssets: pallet_mapped_assets, + FundAdminRecords: pallet_fund_admin_records, } );