@subql/common-substrate 4.4.0 → 4.5.0

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/package.json +17 -4
  4. package/dist/project/load.spec.d.ts +0 -1
  5. package/dist/project/load.spec.js +0 -15
  6. package/dist/project/load.spec.js.map +0 -1
  7. package/dist/project/project.spec.d.ts +0 -1
  8. package/dist/project/project.spec.js +0 -117
  9. package/dist/project/project.spec.js.map +0 -1
  10. package/src/index.ts +0 -14
  11. package/src/project/index.ts +0 -11
  12. package/src/project/load.spec.ts +0 -16
  13. package/src/project/load.ts +0 -34
  14. package/src/project/models.ts +0 -180
  15. package/src/project/project.spec.ts +0 -148
  16. package/src/project/types.ts +0 -25
  17. package/src/project/utils.ts +0 -45
  18. package/src/project/versioned/ProjectManifestVersioned.ts +0 -73
  19. package/src/project/versioned/index.ts +0 -5
  20. package/src/project/versioned/v1_0_0/index.ts +0 -4
  21. package/src/project/versioned/v1_0_0/model.ts +0 -175
  22. package/test/project_1.0.0.yaml +0 -91
  23. package/test/project_1.0.0_bad_processor.yaml +0 -93
  24. package/test/project_1.0.0_bad_runner.yaml +0 -91
  25. package/test/project_1.0.0_bad_runner_version.yaml +0 -91
  26. package/test/project_1.0.0_chainId.yaml +0 -91
  27. package/test/project_1.0.0_custom_ds.yaml +0 -34
  28. package/test/project_1.0.0_falsy.yaml +0 -33
  29. package/test/project_1.0.0_falsy_array.yaml +0 -32
  30. package/test/project_1.0.0_node_options.yaml +0 -94
  31. package/test/project_1.0.0_runner_ds_mismatch.yaml +0 -34
  32. package/test/project_bypass.yaml +0 -36
  33. package/test/project_bypass_range.yaml +0 -36
  34. package/test/project_invalid_version.yaml +0 -29
  35. package/tsconfig.json +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subql/common-substrate",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist && tsc -b",
@@ -14,11 +14,24 @@
14
14
  "main": "dist/index.js",
15
15
  "license": "GPL-3.0",
16
16
  "dependencies": {
17
- "@subql/common": "5.5.0",
18
- "@subql/types": "3.12.1"
17
+ "@subql/common": "5.7.0",
18
+ "@subql/types": "3.13.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "class-transformer": "*",
22
22
  "class-validator": "*"
23
- }
23
+ },
24
+ "files": [
25
+ "/dist",
26
+ "!/dist/**/*.spec.js",
27
+ "!/dist/**/*.spec.d.ts",
28
+ "!/dist/**/*.spec.js.map",
29
+ "!/dist/**/*.test.js",
30
+ "!/dist/**/*.test.d.ts",
31
+ "!/dist/**/*.test.js.map",
32
+ "package.json",
33
+ "README.md",
34
+ "CHANGELOG.md",
35
+ "LICENSE"
36
+ ]
24
37
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- "use strict";
2
- // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
- // SPDX-License-Identifier: GPL-3.0
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- const load_1 = require("./load");
6
- const jsChainTypesScript = `(()=>{"use strict";var e={3412:function(e,n){var t=this&&this.__rest||function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)n.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(t[a[o]]=e[a[o]])}return t};Object.defineProperty(n,"__esModule",{value:!0}),n.typesBundleDeprecated=n.typesBundlePre900=n.moonbeamDefinitionsDeprecated=n.moonbeamDefinitions=n.rpcDefinitions=n.moduleDefinitions=void 0,n.moduleDefinitions={assetManager:{Balance:"TAssetBalance"},xTokens:{Balance:"TAssetBalance"}},n.rpcDefinitions={txpool:{content:{aliasSection:"txpool",description:"The detailed information regarding Ethereum transactions that are currently in the Substrate transaction pool.",params:[],type:"TxPoolResultContent"},inspect:{aliasSection:"txpool",description:"Summarized information of the Ethereum transactions that are currently in the Substrate transaction pool.",params:[],type:"TxPoolResultInspect"},status:{aliasSection:"txpool",description:"The number of Ethereum transaction that are currently in the Substrate transaction pool.",params:[],type:"TxPoolResultStatus"}},trace:{filter:{aliasSection:"trace",description:"Trace Filter",params:[{name:"filter",type:"FilterRequest"}],type:"Result<Vec<TransactionTrace>>"}},debug:{traceTransaction:{aliasSection:"debug",description:"Debug trace tx",params:[{name:"transaction_hash",type:"H256"}],type:"Result<Vec<TransactionTrace>>"}}};const a={AccountId:"EthereumAccountId",Address:"AccountId",Balance:"u128",RefCount:"u8",LookupSource:"AccountId",Account:{nonce:"U256",balance:"u128"}},{RefCount:o}=a,c=t(a,["RefCount"]),i=Object.assign(Object.assign({},c),{ExtrinsicSignature:"EthereumSignature",RoundIndex:"u32",Candidate:{id:"AccountId",fee:"Perbill",bond:"Balance",nominators:"Vec<Bond>",total:"Balance",state:"ValidatorStatus"},Nominator:{nominations:"Vec<Bond>",total:"Balance"},Bond:{owner:"AccountId",amount:"Balance"},ValidatorStatus:{_enum:{Active:"Null",Idle:"Null",Leaving:"RoundIndex"}},TxPoolResultContent:{pending:"HashMap<H160, HashMap<U256, PoolTransaction>>",queued:"HashMap<H160, HashMap<U256, PoolTransaction>>"},TxPoolResultInspect:{pending:"HashMap<H160, HashMap<U256, Summary>>",queued:"HashMap<H160, HashMap<U256, Summary>>"},TxPoolResultStatus:{pending:"U256",queued:"U256"},Summary:"Bytes",PoolTransaction:{hash:"H256",nonce:"U256",blockHash:"Option<H256>",blockNumber:"Option<U256>",from:"H160",to:"Option<H160>",value:"U256",gasPrice:"U256",gas:"U256",input:"Bytes"}}),{ValidatorStatus:s}=i,r=t(i,["ValidatorStatus"]),l=Object.assign(Object.assign({},r),{AccountInfo:"AccountInfoWithTripleRefCount",Candidate:{id:"AccountId",fee:"Perbill",bond:"Balance",nominators:"Vec<Bond>",total:"Balance",state:"CollatorStatus"},CollatorStatus:{_enum:{Active:"Null",Idle:"Null",Leaving:"RoundIndex"}},Range:"RangeBalance",RangeBalance:{min:"Balance",ideal:"Balance",max:"Balance"},RangePerbill:{min:"Perbill",ideal:"Perbill",max:"Perbill"},InflationInfo:{expect:"RangeBalance",annual:"RangePerbill",round:"RangePerbill"},OrderedSet:"Vec<Bond>",Collator:{id:"AccountId",bond:"Balance",nominators:"Vec<Bond>",total:"Balance",state:"CollatorStatus"},CollatorSnapshot:{bond:"Balance",nominators:"Vec<Bond>",total:"Balance"},SystemInherentData:{validationData:"PersistedValidationData",relayChain_state:"StorageProof",downwardMessages:"Vec<InboundDownwardMessage>",horizontalMessages:"BTreeMap<ParaId, Vec<InboundHrmpMessage>>"},RoundInfo:{current:"RoundIndex",first:"BlockNumber",length:"u32"}}),u=Object.assign(Object.assign({},l),{AuthorId:"AccountId"}),d=Object.assign(Object.assign({},u),{AccountId32:"H256",AuthorId:"AccountId32",ProxyType:{_enum:["Any","NonTransfer","Governance","Staking","CancelProxy","Balances","AuthorMapping"]},RelayChainAccountId:"AccountId32",RewardInfo:{totalReward:"Balance",claimedReward:"Balance"}}),m=Object.assign(Object.assign({},d),{Collator2:{id:"AccountId",bond:"Balance",nominators:"Vec<AccountId>",topNominators:"Vec<Bond>",bottomNominators:"Vec<Bond>",totalCounted:"Balance",totalBacking:"Balance",state:"CollatorStatus"},NominatorAdded:{_enum:{AddedToBottom:"Null",AddedToTop:"Balance"}},RegistrationInfo:{account:"AccountId",deposit:"Balance"},ParachainBondConfig:{account:"AccountId",percent:"Percent"}}),p=Object.assign(Object.assign({},m),{EthereumSignature:{r:"H256",s:"H256",v:"U8"},NominatorAdded:{_enum:{AddedToTop:"Balance",AddedToBottom:"Null"}}}),b=Object.assign(Object.assign({},p),{NominatorStatus:{_enum:{Active:"Null",Leaving:"RoundIndex"}},Nominator2:{nominations:"Vec<Bond>",revocations:"Vec<AccountId>",total:"Balance",scheduledRevocationsCount:"u32",scheduledRevocationsTotal:"Balance",status:"NominatorStatus"},ExitQ:{candidates:"Vec<AccountId>",nominatorsLeaving:"Vec<AccountId>",candidateSchedule:"Vec<(AccountId, RoundIndex)>",nominatorSchedule:"Vec<(AccountId, Option<AccountId>, RoundIndex)>"}}),y=Object.assign(Object.assign({},b),{RewardInfo:{totalReward:"Balance",claimedReward:"Balance",contributedRelayAddresses:"Vec<RelayChainAccountId>"}}),I=Object.assign(Object.assign({},y),{AssetType:{_enum:{Xcm:"MultiLocation"}},AssetId:"u128",TAssetBalance:"u128",ENUM_AccountId32:{network:"NetworkId",id:"[u8; 32]"},ENUM_AccountKey20:{network:"NetworkId",key:"[u8; 20]"},ENUM_AccountIndex64:{network:"NetworkId",index:"Compact<u64>"},ENUM_Plurality:{id:"BodyId",part:"BodyPart"},JunctionV0:{_enum:{Parent:"Null",Parachain:"Compact<u32>",AccountId32:"ENUM_AccountId32",AccountIndex64:"ENUM_AccountIndex64",AccountKey20:"ENUM_AccountKey20",PalletInstance:"u8",GeneralIndex:"Compact<u128>",GeneralKey:"Vec<u8>",OnlyChild:"Null",Plurality:"ENUM_Plurality"}},CurrencyId:{_enum:{SelfReserve:"Null",OtherReserve:"u128"}},AssetRegistrarMetadata:{name:"Vec<u8>",symbol:"Vec<u8>",decimals:"u8",isFrozen:"bool"},VestingBlockNumber:"u32",MultiLocation:"MultiLocationV0"}),A=Object.assign(Object.assign({},I),{JunctionV1:{_enum:{Parachain:"Compact<u32>",AccountId32:"ENUM_AccountId32",AccountIndex64:"ENUM_AccountIndex64",AccountKey20:"ENUM_AccountKey20",PalletInstance:"u8",GeneralIndex:"Compact<u128>",GeneralKey:"Vec<u8>",OnlyChild:"Null",Plurality:"ENUM_Plurality"}},MultiLocation:"MultiLocationV1"}),g=Object.assign(Object.assign({},A),{MoonbaseRuntimeAssetRegistrarMetadata:{name:"Vec<u8>",symbol:"Vec<u8>",decimals:"u8",is_frozen:"bool"},PalletCrowdloanRewardsRewardInfo:{total_reward:"Balance",claimed_reward:"Balance",contributed_relay_addresses:"Vec<RelayChainAccountId>"},ParachainStakingNominator2:{nominations:"Vec<Bond>",revocations:"Vec<AccountId>",total:"Balance",scheduled_revocations_count:"u32",scheduled_revocations_total:"Balance",status:"NominatorStatus"},ParachainStakingExitQ:{candidates:"Vec<AccountId>",nominators_leaving:"Vec<AccountId>",candidate_schedule:"Vec<(AccountId, RoundIndex)>",nominator_schedule:"Vec<(AccountId, Option<AccountId>, RoundIndex)>"},ParachainStakingCollator2:{id:"AccountId",bond:"Balance",nominators:"Vec<AccountId>",top_nominators:"Vec<Bond>",bottom_nominators:"Vec<Bond>",total_counted:"Balance",total_backing:"Balance",state:"CollatorStatus"}});n.moonbeamDefinitions={alias:n.moduleDefinitions,rpc:n.rpcDefinitions,instances:{council:["councilCollective"],technicalCommittee:["techCommitteeCollective"]},types:[{minmax:[0,4],types:a},{minmax:[5,5],types:c},{minmax:[6,19],types:i},{minmax:[19,35],types:l},{minmax:[36,36],types:u},{minmax:[37,42],types:d},{minmax:[43,154],types:m},{minmax:[155,199],types:p},{minmax:[200,399],types:b},{minmax:[400,599],types:y},{minmax:[600,799],types:I},{minmax:[800,899],types:A},{minmax:[900,void 0],types:{ProxyType:{_enum:["Any","NonTransfer","Governance","Staking","CancelProxy","Balances","AuthorMapping"]}}}]},n.moonbeamDefinitionsDeprecated=Object.assign(Object.assign({},n.moonbeamDefinitions),{types:[...n.moonbeamDefinitions.types,{minmax:[900,void 0],types:g}]}),n.typesBundlePre900={spec:{moonbeam:n.moonbeamDefinitions,moonbeamDefinitions:n.moonbeamDefinitions,moonbase:n.moonbeamDefinitions,moonriver:n.moonbeamDefinitions}},n.typesBundleDeprecated={spec:{moonbeam:n.moonbeamDefinitionsDeprecated,moonbeamDefinitions:n.moonbeamDefinitionsDeprecated,moonbase:n.moonbeamDefinitionsDeprecated,moonriver:n.moonbeamDefinitionsDeprecated}}}},n={};function t(a){var o=n[a];if(void 0!==o)return o.exports;var c=n[a]={exports:{}};return e[a].call(c.exports,c,c.exports,t),c.exports}var a={};(()=>{var e=a;Object.defineProperty(e,"__esModule",{value:!0});const n=t(3412);e.default={typesBundle:n.typesBundleDeprecated}})();var o=exports;for(var c in a)o[c]=a[c];a.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();`;
7
- describe('load', () => {
8
- it('throw error on incorrect format chain types', () => {
9
- expect(() => (0, load_1.parseChainTypes)(jsChainTypesScript)).toThrow();
10
- });
11
- it.skip('can load yaml and json format chain types', () => {
12
- expect((0, load_1.parseChainTypes)(jsChainTypesScript)).not.toThrow();
13
- });
14
- });
15
- //# sourceMappingURL=load.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"load.spec.js","sourceRoot":"","sources":["../../src/project/load.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,iCAAuC;AAEvC,MAAM,kBAAkB,GAAG,+hRAA+hR,CAAC;AAE3jR,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,sBAAe,EAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,IAAA,sBAAe,EAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {parseChainTypes} from './load';\n\nconst jsChainTypesScript = `(()=>{\"use strict\";var e={3412:function(e,n){var t=this&&this.__rest||function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&\"function\"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)n.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(t[a[o]]=e[a[o]])}return t};Object.defineProperty(n,\"__esModule\",{value:!0}),n.typesBundleDeprecated=n.typesBundlePre900=n.moonbeamDefinitionsDeprecated=n.moonbeamDefinitions=n.rpcDefinitions=n.moduleDefinitions=void 0,n.moduleDefinitions={assetManager:{Balance:\"TAssetBalance\"},xTokens:{Balance:\"TAssetBalance\"}},n.rpcDefinitions={txpool:{content:{aliasSection:\"txpool\",description:\"The detailed information regarding Ethereum transactions that are currently in the Substrate transaction pool.\",params:[],type:\"TxPoolResultContent\"},inspect:{aliasSection:\"txpool\",description:\"Summarized information of the Ethereum transactions that are currently in the Substrate transaction pool.\",params:[],type:\"TxPoolResultInspect\"},status:{aliasSection:\"txpool\",description:\"The number of Ethereum transaction that are currently in the Substrate transaction pool.\",params:[],type:\"TxPoolResultStatus\"}},trace:{filter:{aliasSection:\"trace\",description:\"Trace Filter\",params:[{name:\"filter\",type:\"FilterRequest\"}],type:\"Result<Vec<TransactionTrace>>\"}},debug:{traceTransaction:{aliasSection:\"debug\",description:\"Debug trace tx\",params:[{name:\"transaction_hash\",type:\"H256\"}],type:\"Result<Vec<TransactionTrace>>\"}}};const a={AccountId:\"EthereumAccountId\",Address:\"AccountId\",Balance:\"u128\",RefCount:\"u8\",LookupSource:\"AccountId\",Account:{nonce:\"U256\",balance:\"u128\"}},{RefCount:o}=a,c=t(a,[\"RefCount\"]),i=Object.assign(Object.assign({},c),{ExtrinsicSignature:\"EthereumSignature\",RoundIndex:\"u32\",Candidate:{id:\"AccountId\",fee:\"Perbill\",bond:\"Balance\",nominators:\"Vec<Bond>\",total:\"Balance\",state:\"ValidatorStatus\"},Nominator:{nominations:\"Vec<Bond>\",total:\"Balance\"},Bond:{owner:\"AccountId\",amount:\"Balance\"},ValidatorStatus:{_enum:{Active:\"Null\",Idle:\"Null\",Leaving:\"RoundIndex\"}},TxPoolResultContent:{pending:\"HashMap<H160, HashMap<U256, PoolTransaction>>\",queued:\"HashMap<H160, HashMap<U256, PoolTransaction>>\"},TxPoolResultInspect:{pending:\"HashMap<H160, HashMap<U256, Summary>>\",queued:\"HashMap<H160, HashMap<U256, Summary>>\"},TxPoolResultStatus:{pending:\"U256\",queued:\"U256\"},Summary:\"Bytes\",PoolTransaction:{hash:\"H256\",nonce:\"U256\",blockHash:\"Option<H256>\",blockNumber:\"Option<U256>\",from:\"H160\",to:\"Option<H160>\",value:\"U256\",gasPrice:\"U256\",gas:\"U256\",input:\"Bytes\"}}),{ValidatorStatus:s}=i,r=t(i,[\"ValidatorStatus\"]),l=Object.assign(Object.assign({},r),{AccountInfo:\"AccountInfoWithTripleRefCount\",Candidate:{id:\"AccountId\",fee:\"Perbill\",bond:\"Balance\",nominators:\"Vec<Bond>\",total:\"Balance\",state:\"CollatorStatus\"},CollatorStatus:{_enum:{Active:\"Null\",Idle:\"Null\",Leaving:\"RoundIndex\"}},Range:\"RangeBalance\",RangeBalance:{min:\"Balance\",ideal:\"Balance\",max:\"Balance\"},RangePerbill:{min:\"Perbill\",ideal:\"Perbill\",max:\"Perbill\"},InflationInfo:{expect:\"RangeBalance\",annual:\"RangePerbill\",round:\"RangePerbill\"},OrderedSet:\"Vec<Bond>\",Collator:{id:\"AccountId\",bond:\"Balance\",nominators:\"Vec<Bond>\",total:\"Balance\",state:\"CollatorStatus\"},CollatorSnapshot:{bond:\"Balance\",nominators:\"Vec<Bond>\",total:\"Balance\"},SystemInherentData:{validationData:\"PersistedValidationData\",relayChain_state:\"StorageProof\",downwardMessages:\"Vec<InboundDownwardMessage>\",horizontalMessages:\"BTreeMap<ParaId, Vec<InboundHrmpMessage>>\"},RoundInfo:{current:\"RoundIndex\",first:\"BlockNumber\",length:\"u32\"}}),u=Object.assign(Object.assign({},l),{AuthorId:\"AccountId\"}),d=Object.assign(Object.assign({},u),{AccountId32:\"H256\",AuthorId:\"AccountId32\",ProxyType:{_enum:[\"Any\",\"NonTransfer\",\"Governance\",\"Staking\",\"CancelProxy\",\"Balances\",\"AuthorMapping\"]},RelayChainAccountId:\"AccountId32\",RewardInfo:{totalReward:\"Balance\",claimedReward:\"Balance\"}}),m=Object.assign(Object.assign({},d),{Collator2:{id:\"AccountId\",bond:\"Balance\",nominators:\"Vec<AccountId>\",topNominators:\"Vec<Bond>\",bottomNominators:\"Vec<Bond>\",totalCounted:\"Balance\",totalBacking:\"Balance\",state:\"CollatorStatus\"},NominatorAdded:{_enum:{AddedToBottom:\"Null\",AddedToTop:\"Balance\"}},RegistrationInfo:{account:\"AccountId\",deposit:\"Balance\"},ParachainBondConfig:{account:\"AccountId\",percent:\"Percent\"}}),p=Object.assign(Object.assign({},m),{EthereumSignature:{r:\"H256\",s:\"H256\",v:\"U8\"},NominatorAdded:{_enum:{AddedToTop:\"Balance\",AddedToBottom:\"Null\"}}}),b=Object.assign(Object.assign({},p),{NominatorStatus:{_enum:{Active:\"Null\",Leaving:\"RoundIndex\"}},Nominator2:{nominations:\"Vec<Bond>\",revocations:\"Vec<AccountId>\",total:\"Balance\",scheduledRevocationsCount:\"u32\",scheduledRevocationsTotal:\"Balance\",status:\"NominatorStatus\"},ExitQ:{candidates:\"Vec<AccountId>\",nominatorsLeaving:\"Vec<AccountId>\",candidateSchedule:\"Vec<(AccountId, RoundIndex)>\",nominatorSchedule:\"Vec<(AccountId, Option<AccountId>, RoundIndex)>\"}}),y=Object.assign(Object.assign({},b),{RewardInfo:{totalReward:\"Balance\",claimedReward:\"Balance\",contributedRelayAddresses:\"Vec<RelayChainAccountId>\"}}),I=Object.assign(Object.assign({},y),{AssetType:{_enum:{Xcm:\"MultiLocation\"}},AssetId:\"u128\",TAssetBalance:\"u128\",ENUM_AccountId32:{network:\"NetworkId\",id:\"[u8; 32]\"},ENUM_AccountKey20:{network:\"NetworkId\",key:\"[u8; 20]\"},ENUM_AccountIndex64:{network:\"NetworkId\",index:\"Compact<u64>\"},ENUM_Plurality:{id:\"BodyId\",part:\"BodyPart\"},JunctionV0:{_enum:{Parent:\"Null\",Parachain:\"Compact<u32>\",AccountId32:\"ENUM_AccountId32\",AccountIndex64:\"ENUM_AccountIndex64\",AccountKey20:\"ENUM_AccountKey20\",PalletInstance:\"u8\",GeneralIndex:\"Compact<u128>\",GeneralKey:\"Vec<u8>\",OnlyChild:\"Null\",Plurality:\"ENUM_Plurality\"}},CurrencyId:{_enum:{SelfReserve:\"Null\",OtherReserve:\"u128\"}},AssetRegistrarMetadata:{name:\"Vec<u8>\",symbol:\"Vec<u8>\",decimals:\"u8\",isFrozen:\"bool\"},VestingBlockNumber:\"u32\",MultiLocation:\"MultiLocationV0\"}),A=Object.assign(Object.assign({},I),{JunctionV1:{_enum:{Parachain:\"Compact<u32>\",AccountId32:\"ENUM_AccountId32\",AccountIndex64:\"ENUM_AccountIndex64\",AccountKey20:\"ENUM_AccountKey20\",PalletInstance:\"u8\",GeneralIndex:\"Compact<u128>\",GeneralKey:\"Vec<u8>\",OnlyChild:\"Null\",Plurality:\"ENUM_Plurality\"}},MultiLocation:\"MultiLocationV1\"}),g=Object.assign(Object.assign({},A),{MoonbaseRuntimeAssetRegistrarMetadata:{name:\"Vec<u8>\",symbol:\"Vec<u8>\",decimals:\"u8\",is_frozen:\"bool\"},PalletCrowdloanRewardsRewardInfo:{total_reward:\"Balance\",claimed_reward:\"Balance\",contributed_relay_addresses:\"Vec<RelayChainAccountId>\"},ParachainStakingNominator2:{nominations:\"Vec<Bond>\",revocations:\"Vec<AccountId>\",total:\"Balance\",scheduled_revocations_count:\"u32\",scheduled_revocations_total:\"Balance\",status:\"NominatorStatus\"},ParachainStakingExitQ:{candidates:\"Vec<AccountId>\",nominators_leaving:\"Vec<AccountId>\",candidate_schedule:\"Vec<(AccountId, RoundIndex)>\",nominator_schedule:\"Vec<(AccountId, Option<AccountId>, RoundIndex)>\"},ParachainStakingCollator2:{id:\"AccountId\",bond:\"Balance\",nominators:\"Vec<AccountId>\",top_nominators:\"Vec<Bond>\",bottom_nominators:\"Vec<Bond>\",total_counted:\"Balance\",total_backing:\"Balance\",state:\"CollatorStatus\"}});n.moonbeamDefinitions={alias:n.moduleDefinitions,rpc:n.rpcDefinitions,instances:{council:[\"councilCollective\"],technicalCommittee:[\"techCommitteeCollective\"]},types:[{minmax:[0,4],types:a},{minmax:[5,5],types:c},{minmax:[6,19],types:i},{minmax:[19,35],types:l},{minmax:[36,36],types:u},{minmax:[37,42],types:d},{minmax:[43,154],types:m},{minmax:[155,199],types:p},{minmax:[200,399],types:b},{minmax:[400,599],types:y},{minmax:[600,799],types:I},{minmax:[800,899],types:A},{minmax:[900,void 0],types:{ProxyType:{_enum:[\"Any\",\"NonTransfer\",\"Governance\",\"Staking\",\"CancelProxy\",\"Balances\",\"AuthorMapping\"]}}}]},n.moonbeamDefinitionsDeprecated=Object.assign(Object.assign({},n.moonbeamDefinitions),{types:[...n.moonbeamDefinitions.types,{minmax:[900,void 0],types:g}]}),n.typesBundlePre900={spec:{moonbeam:n.moonbeamDefinitions,moonbeamDefinitions:n.moonbeamDefinitions,moonbase:n.moonbeamDefinitions,moonriver:n.moonbeamDefinitions}},n.typesBundleDeprecated={spec:{moonbeam:n.moonbeamDefinitionsDeprecated,moonbeamDefinitions:n.moonbeamDefinitionsDeprecated,moonbase:n.moonbeamDefinitionsDeprecated,moonriver:n.moonbeamDefinitionsDeprecated}}}},n={};function t(a){var o=n[a];if(void 0!==o)return o.exports;var c=n[a]={exports:{}};return e[a].call(c.exports,c,c.exports,t),c.exports}var a={};(()=>{var e=a;Object.defineProperty(e,\"__esModule\",{value:!0});const n=t(3412);e.default={typesBundle:n.typesBundleDeprecated}})();var o=exports;for(var c in a)o[c]=a[c];a.__esModule&&Object.defineProperty(o,\"__esModule\",{value:!0})})();`;\n\ndescribe('load', () => {\n it('throw error on incorrect format chain types', () => {\n expect(() => parseChainTypes(jsChainTypesScript)).toThrow();\n });\n\n it.skip('can load yaml and json format chain types', () => {\n expect(parseChainTypes(jsChainTypesScript)).not.toThrow();\n });\n});\n"]}
@@ -1 +0,0 @@
1
- export {};
@@ -1,117 +0,0 @@
1
- "use strict";
2
- // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
- // SPDX-License-Identifier: GPL-3.0
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const path_1 = __importDefault(require("path"));
9
- const common_1 = require("@subql/common");
10
- const class_validator_1 = require("class-validator");
11
- const v1_0_0_1 = require("../project/versioned/v1_0_0");
12
- const versioned_1 = require("./versioned");
13
- const projectsDir = path_1.default.join(__dirname, '../../test');
14
- function loadSubstrateProjectManifest(file) {
15
- const doc = (0, common_1.loadFromJsonOrYaml)((0, common_1.getManifestPath)(file));
16
- const projectManifest = new versioned_1.SubstrateProjectManifestVersioned(doc);
17
- projectManifest.validate();
18
- return projectManifest;
19
- }
20
- describe('project.yaml', () => {
21
- it('can validate project.yaml', () => {
22
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_falsy.yaml'))).toThrow();
23
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_falsy_array.yaml'))).toThrow();
24
- });
25
- it('can fail validation if version not supported', () => {
26
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_invalid_version.yaml'))).toThrow();
27
- });
28
- it('can validate a v1.0.0 project.yaml with a custom data source', () => {
29
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0_custom_ds.yaml'))).not.toThrow();
30
- });
31
- it('can validate a v1.0.0 project.yaml with templates', () => {
32
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0.yaml'))).not.toThrow();
33
- });
34
- it('can convert genesis hash in v1.0.0 to chainId in deployment', () => {
35
- const deployment = loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0.yaml')).asV1_0_0.deployment;
36
- expect(deployment.network.chainId).not.toBeNull();
37
- });
38
- it('can get chainId for deployment', () => {
39
- const deployment = loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0_chainId.yaml')).asV1_0_0
40
- .deployment;
41
- expect(deployment.network.chainId).toBe('moonbeamChainId');
42
- });
43
- it('can get runner options for deployment', () => {
44
- const deployment = loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0_node_options.yaml')).asV1_0_0
45
- .deployment;
46
- expect(deployment.runner.node.options?.unsafe).toBeTruthy();
47
- });
48
- it('can validate deployment runner versions', () => {
49
- const deployment = new v1_0_0_1.DeploymentV1_0_0();
50
- const nodeImp = new v1_0_0_1.SubstrateRunnerNodeImpl();
51
- const queryImp = new common_1.RunnerQueryBaseModel();
52
- deployment.specVersion = '1.0.0';
53
- deployment.runner = new v1_0_0_1.SubstrateRunnerSpecsImpl();
54
- nodeImp.name = '@subql/node';
55
- nodeImp.version = '0.29.1';
56
- deployment.runner.node = nodeImp;
57
- queryImp.name = '@subql/query';
58
- queryImp.version = '0.213.1';
59
- deployment.runner.query = queryImp;
60
- (0, class_validator_1.validateSync)(deployment.runner, { whitelist: true, forbidNonWhitelisted: true });
61
- });
62
- it('can validate bypass blocks', () => {
63
- const deployment = loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_bypass.yaml')).asV1_0_0.deployment;
64
- const range_deployment = loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_bypass_range.yaml')).asV1_0_0
65
- .deployment;
66
- expect(deployment.network.bypassBlocks).not.toBeNull();
67
- expect(range_deployment.network.bypassBlocks).not.toBeNull();
68
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_bypass.yaml'))).not.toThrow();
69
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_bypass_range.yaml'))).not.toThrow();
70
- });
71
- it('can validate a v1.0.0 project.yaml with unsupported runner node', () => {
72
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0_bad_runner.yaml'))).toThrow();
73
- });
74
- it('can throw error with unsupported runner version', () => {
75
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0_bad_runner_version.yaml'))).toThrow();
76
- });
77
- it('can validate a v1.0.0 project.yaml runner and datasource mismatches', () => {
78
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0_runner_ds_mismatch.yaml'))).toThrow();
79
- });
80
- it('can fail validation if custom ds missing processor', () => {
81
- expect(() => loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_0.2.0_invalid_custom_ds.yaml'))).toThrow();
82
- });
83
- it('can convert project with assets to deployment', () => {
84
- const manifest = loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0.yaml'));
85
- expect(manifest.isV1_0_0).toBeTruthy();
86
- expect(() => manifest.toDeployment()).not.toThrow();
87
- });
88
- it('validate versions', () => {
89
- const checkVersion = new common_1.SemverVersionValidator();
90
- // Versions
91
- expect(checkVersion.validate('*')).toBeTruthy();
92
- expect(checkVersion.validate('0.0.0')).toBeTruthy();
93
- expect(checkVersion.validate('0.1.0')).toBeTruthy();
94
- expect(checkVersion.validate('1.2.0')).toBeTruthy();
95
- expect(checkVersion.validate('^0.0.0')).toBeTruthy();
96
- expect(checkVersion.validate('>=0.1.0')).toBeTruthy();
97
- expect(checkVersion.validate('<0.1.1-1')).toBeTruthy();
98
- expect(checkVersion.validate('>=1.2.0')).toBeTruthy();
99
- expect(checkVersion.validate('~1.2.0-1')).toBeTruthy();
100
- expect(checkVersion.validate('>=1.2.0-abc')).toBeTruthy();
101
- expect(checkVersion.validate('0.1.1-1')).toBeFalsy();
102
- expect(checkVersion.validate('1.2.0-1')).toBeFalsy();
103
- expect(checkVersion.validate('1.2.0-abc')).toBeFalsy();
104
- expect(checkVersion.validate('~')).toBeFalsy();
105
- expect(checkVersion.validate('latest')).toBeFalsy();
106
- expect(checkVersion.validate('dev')).toBeFalsy();
107
- });
108
- it('Preserve Map content on deployment', () => {
109
- const manifest = loadSubstrateProjectManifest(path_1.default.join(projectsDir, 'project_1.0.0.yaml'));
110
- expect((0, common_1.toJsonObject)(manifest.asImpl.deployment.dataSources[0]).assets).toEqual({
111
- settings: {
112
- file: './src/settings.abi.json',
113
- },
114
- });
115
- });
116
- });
117
- //# sourceMappingURL=project.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project.spec.js","sourceRoot":"","sources":["../../src/project/project.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;AAEnC,gDAAwB;AACxB,0CAMuB;AACvB,qDAA6C;AAC7C,wDAAgH;AAChH,2CAAwF;AAExF,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAEvD,SAAS,4BAA4B,CAAC,IAAY;IAChD,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAA,wBAAe,EAAC,IAAI,CAAC,CAAC,CAAC;IACtD,MAAM,eAAe,GAAG,IAAI,6CAAiC,CAAC,GAA+B,CAAC,CAAC;IAC/F,eAAe,CAAC,QAAQ,EAAE,CAAC;IAC3B,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,GAAG,EAAE,CAAC,4BAA4B,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACnG,MAAM,CAAC,GAAG,EAAE,CAAC,4BAA4B,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3G,CAAC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-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport path from 'path';\nimport {\n getManifestPath,\n loadFromJsonOrYaml,\n RunnerQueryBaseModel,\n SemverVersionValidator,\n toJsonObject,\n} from '@subql/common';\nimport {validateSync} from 'class-validator';\nimport {DeploymentV1_0_0, SubstrateRunnerNodeImpl, SubstrateRunnerSpecsImpl} from '../project/versioned/v1_0_0';\nimport {SubstrateProjectManifestVersioned, VersionedProjectManifest} from './versioned';\n\nconst projectsDir = path.join(__dirname, '../../test');\n\nfunction loadSubstrateProjectManifest(file: string): SubstrateProjectManifestVersioned {\n const doc = loadFromJsonOrYaml(getManifestPath(file));\n const projectManifest = new SubstrateProjectManifestVersioned(doc as VersionedProjectManifest);\n projectManifest.validate();\n return projectManifest;\n}\n\ndescribe('project.yaml', () => {\n it('can validate project.yaml', () => {\n expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_falsy.yaml'))).toThrow();\n expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_falsy_array.yaml'))).toThrow();\n });\n\n it('can fail validation if version not supported', () => {\n expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_invalid_version.yaml'))).toThrow();\n });\n it('can validate a v1.0.0 project.yaml with a custom data source', () => {\n expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_custom_ds.yaml'))).not.toThrow();\n });\n it('can validate a v1.0.0 project.yaml with templates', () => {\n expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml'))).not.toThrow();\n });\n\n it('can convert genesis hash in v1.0.0 to chainId in deployment', () => {\n const deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml')).asV1_0_0.deployment;\n expect(deployment.network.chainId).not.toBeNull();\n });\n\n it('can get chainId for deployment', () => {\n const deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_chainId.yaml')).asV1_0_0\n .deployment;\n expect(deployment.network.chainId).toBe('moonbeamChainId');\n });\n\n it('can get runner options for deployment', () => {\n const deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_node_options.yaml')).asV1_0_0\n .deployment;\n expect(deployment.runner.node.options?.unsafe).toBeTruthy();\n });\n\n it('can validate deployment runner versions', () => {\n const deployment = new DeploymentV1_0_0();\n const nodeImp = new SubstrateRunnerNodeImpl();\n const queryImp = new RunnerQueryBaseModel();\n deployment.specVersion = '1.0.0';\n deployment.runner = new SubstrateRunnerSpecsImpl();\n\n nodeImp.name = '@subql/node';\n nodeImp.version = '0.29.1';\n deployment.runner.node = nodeImp;\n\n queryImp.name = '@subql/query';\n queryImp.version = '0.213.1';\n\n deployment.runner.query = queryImp;\n\n validateSync(deployment.runner, {whitelist: true, forbidNonWhitelisted: true});\n });\n\n it('can validate bypass blocks', () => {\n const deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_bypass.yaml')).asV1_0_0.deployment;\n const range_deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_bypass_range.yaml')).asV1_0_0\n .deployment;\n\n expect(deployment.network.bypassBlocks).not.toBeNull();\n expect(range_deployment.network.bypassBlocks).not.toBeNull();\n\n expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_bypass.yaml'))).not.toThrow();\n expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_bypass_range.yaml'))).not.toThrow();\n });\n\n it('can validate a v1.0.0 project.yaml with unsupported runner node', () => {\n expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_bad_runner.yaml'))).toThrow();\n });\n\n it('can throw error with unsupported runner version', () => {\n expect(() =>\n loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_bad_runner_version.yaml'))\n ).toThrow();\n });\n\n it('can validate a v1.0.0 project.yaml runner and datasource mismatches', () => {\n expect(() =>\n loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_runner_ds_mismatch.yaml'))\n ).toThrow();\n });\n\n it('can fail validation if custom ds missing processor', () => {\n expect(() =>\n loadSubstrateProjectManifest(path.join(projectsDir, 'project_0.2.0_invalid_custom_ds.yaml'))\n ).toThrow();\n });\n\n it('can convert project with assets to deployment', () => {\n const manifest = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml'));\n expect(manifest.isV1_0_0).toBeTruthy();\n expect(() => manifest.toDeployment()).not.toThrow();\n });\n\n it('validate versions', () => {\n const checkVersion = new SemverVersionValidator();\n // Versions\n expect(checkVersion.validate('*')).toBeTruthy();\n expect(checkVersion.validate('0.0.0')).toBeTruthy();\n expect(checkVersion.validate('0.1.0')).toBeTruthy();\n expect(checkVersion.validate('1.2.0')).toBeTruthy();\n expect(checkVersion.validate('^0.0.0')).toBeTruthy();\n expect(checkVersion.validate('>=0.1.0')).toBeTruthy();\n expect(checkVersion.validate('<0.1.1-1')).toBeTruthy();\n expect(checkVersion.validate('>=1.2.0')).toBeTruthy();\n expect(checkVersion.validate('~1.2.0-1')).toBeTruthy();\n expect(checkVersion.validate('>=1.2.0-abc')).toBeTruthy();\n\n expect(checkVersion.validate('0.1.1-1')).toBeFalsy();\n expect(checkVersion.validate('1.2.0-1')).toBeFalsy();\n expect(checkVersion.validate('1.2.0-abc')).toBeFalsy();\n expect(checkVersion.validate('~')).toBeFalsy();\n expect(checkVersion.validate('latest')).toBeFalsy();\n expect(checkVersion.validate('dev')).toBeFalsy();\n });\n\n it('Preserve Map content on deployment', () => {\n const manifest = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml'));\n\n expect((toJsonObject(manifest.asImpl.deployment.dataSources[0]) as any).assets).toEqual({\n settings: {\n file: './src/settings.abi.json',\n },\n });\n });\n});\n"]}
package/src/index.ts DELETED
@@ -1,14 +0,0 @@
1
- // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
2
- // SPDX-License-Identifier: GPL-3.0
3
-
4
- export * from './project';
5
-
6
- import {SubstrateCustomDatasource, SubstrateDatasource, SubstrateRuntimeDatasource} from '@subql/types';
7
- import {INetworkCommonModule} from '@subql/types-core';
8
- import * as p from './project';
9
-
10
- // This provides a compiled time check to ensure that the correct exports are provided
11
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
- const _ = {
13
- ...p,
14
- } satisfies INetworkCommonModule<SubstrateDatasource, SubstrateRuntimeDatasource, SubstrateCustomDatasource>;
@@ -1,11 +0,0 @@
1
- // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
2
- // SPDX-License-Identifier: GPL-3.0
3
-
4
- export * from './load';
5
- export * from './models';
6
- export * from './types';
7
- export * from './utils';
8
- export * from './versioned';
9
-
10
- import {parseSubstrateProjectManifest} from './load';
11
- export {parseSubstrateProjectManifest as parseProjectManifest};
@@ -1,16 +0,0 @@
1
- // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
2
- // SPDX-License-Identifier: GPL-3.0
3
-
4
- import {parseChainTypes} from './load';
5
-
6
- const jsChainTypesScript = `(()=>{"use strict";var e={3412:function(e,n){var t=this&&this.__rest||function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)n.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(t[a[o]]=e[a[o]])}return t};Object.defineProperty(n,"__esModule",{value:!0}),n.typesBundleDeprecated=n.typesBundlePre900=n.moonbeamDefinitionsDeprecated=n.moonbeamDefinitions=n.rpcDefinitions=n.moduleDefinitions=void 0,n.moduleDefinitions={assetManager:{Balance:"TAssetBalance"},xTokens:{Balance:"TAssetBalance"}},n.rpcDefinitions={txpool:{content:{aliasSection:"txpool",description:"The detailed information regarding Ethereum transactions that are currently in the Substrate transaction pool.",params:[],type:"TxPoolResultContent"},inspect:{aliasSection:"txpool",description:"Summarized information of the Ethereum transactions that are currently in the Substrate transaction pool.",params:[],type:"TxPoolResultInspect"},status:{aliasSection:"txpool",description:"The number of Ethereum transaction that are currently in the Substrate transaction pool.",params:[],type:"TxPoolResultStatus"}},trace:{filter:{aliasSection:"trace",description:"Trace Filter",params:[{name:"filter",type:"FilterRequest"}],type:"Result<Vec<TransactionTrace>>"}},debug:{traceTransaction:{aliasSection:"debug",description:"Debug trace tx",params:[{name:"transaction_hash",type:"H256"}],type:"Result<Vec<TransactionTrace>>"}}};const a={AccountId:"EthereumAccountId",Address:"AccountId",Balance:"u128",RefCount:"u8",LookupSource:"AccountId",Account:{nonce:"U256",balance:"u128"}},{RefCount:o}=a,c=t(a,["RefCount"]),i=Object.assign(Object.assign({},c),{ExtrinsicSignature:"EthereumSignature",RoundIndex:"u32",Candidate:{id:"AccountId",fee:"Perbill",bond:"Balance",nominators:"Vec<Bond>",total:"Balance",state:"ValidatorStatus"},Nominator:{nominations:"Vec<Bond>",total:"Balance"},Bond:{owner:"AccountId",amount:"Balance"},ValidatorStatus:{_enum:{Active:"Null",Idle:"Null",Leaving:"RoundIndex"}},TxPoolResultContent:{pending:"HashMap<H160, HashMap<U256, PoolTransaction>>",queued:"HashMap<H160, HashMap<U256, PoolTransaction>>"},TxPoolResultInspect:{pending:"HashMap<H160, HashMap<U256, Summary>>",queued:"HashMap<H160, HashMap<U256, Summary>>"},TxPoolResultStatus:{pending:"U256",queued:"U256"},Summary:"Bytes",PoolTransaction:{hash:"H256",nonce:"U256",blockHash:"Option<H256>",blockNumber:"Option<U256>",from:"H160",to:"Option<H160>",value:"U256",gasPrice:"U256",gas:"U256",input:"Bytes"}}),{ValidatorStatus:s}=i,r=t(i,["ValidatorStatus"]),l=Object.assign(Object.assign({},r),{AccountInfo:"AccountInfoWithTripleRefCount",Candidate:{id:"AccountId",fee:"Perbill",bond:"Balance",nominators:"Vec<Bond>",total:"Balance",state:"CollatorStatus"},CollatorStatus:{_enum:{Active:"Null",Idle:"Null",Leaving:"RoundIndex"}},Range:"RangeBalance",RangeBalance:{min:"Balance",ideal:"Balance",max:"Balance"},RangePerbill:{min:"Perbill",ideal:"Perbill",max:"Perbill"},InflationInfo:{expect:"RangeBalance",annual:"RangePerbill",round:"RangePerbill"},OrderedSet:"Vec<Bond>",Collator:{id:"AccountId",bond:"Balance",nominators:"Vec<Bond>",total:"Balance",state:"CollatorStatus"},CollatorSnapshot:{bond:"Balance",nominators:"Vec<Bond>",total:"Balance"},SystemInherentData:{validationData:"PersistedValidationData",relayChain_state:"StorageProof",downwardMessages:"Vec<InboundDownwardMessage>",horizontalMessages:"BTreeMap<ParaId, Vec<InboundHrmpMessage>>"},RoundInfo:{current:"RoundIndex",first:"BlockNumber",length:"u32"}}),u=Object.assign(Object.assign({},l),{AuthorId:"AccountId"}),d=Object.assign(Object.assign({},u),{AccountId32:"H256",AuthorId:"AccountId32",ProxyType:{_enum:["Any","NonTransfer","Governance","Staking","CancelProxy","Balances","AuthorMapping"]},RelayChainAccountId:"AccountId32",RewardInfo:{totalReward:"Balance",claimedReward:"Balance"}}),m=Object.assign(Object.assign({},d),{Collator2:{id:"AccountId",bond:"Balance",nominators:"Vec<AccountId>",topNominators:"Vec<Bond>",bottomNominators:"Vec<Bond>",totalCounted:"Balance",totalBacking:"Balance",state:"CollatorStatus"},NominatorAdded:{_enum:{AddedToBottom:"Null",AddedToTop:"Balance"}},RegistrationInfo:{account:"AccountId",deposit:"Balance"},ParachainBondConfig:{account:"AccountId",percent:"Percent"}}),p=Object.assign(Object.assign({},m),{EthereumSignature:{r:"H256",s:"H256",v:"U8"},NominatorAdded:{_enum:{AddedToTop:"Balance",AddedToBottom:"Null"}}}),b=Object.assign(Object.assign({},p),{NominatorStatus:{_enum:{Active:"Null",Leaving:"RoundIndex"}},Nominator2:{nominations:"Vec<Bond>",revocations:"Vec<AccountId>",total:"Balance",scheduledRevocationsCount:"u32",scheduledRevocationsTotal:"Balance",status:"NominatorStatus"},ExitQ:{candidates:"Vec<AccountId>",nominatorsLeaving:"Vec<AccountId>",candidateSchedule:"Vec<(AccountId, RoundIndex)>",nominatorSchedule:"Vec<(AccountId, Option<AccountId>, RoundIndex)>"}}),y=Object.assign(Object.assign({},b),{RewardInfo:{totalReward:"Balance",claimedReward:"Balance",contributedRelayAddresses:"Vec<RelayChainAccountId>"}}),I=Object.assign(Object.assign({},y),{AssetType:{_enum:{Xcm:"MultiLocation"}},AssetId:"u128",TAssetBalance:"u128",ENUM_AccountId32:{network:"NetworkId",id:"[u8; 32]"},ENUM_AccountKey20:{network:"NetworkId",key:"[u8; 20]"},ENUM_AccountIndex64:{network:"NetworkId",index:"Compact<u64>"},ENUM_Plurality:{id:"BodyId",part:"BodyPart"},JunctionV0:{_enum:{Parent:"Null",Parachain:"Compact<u32>",AccountId32:"ENUM_AccountId32",AccountIndex64:"ENUM_AccountIndex64",AccountKey20:"ENUM_AccountKey20",PalletInstance:"u8",GeneralIndex:"Compact<u128>",GeneralKey:"Vec<u8>",OnlyChild:"Null",Plurality:"ENUM_Plurality"}},CurrencyId:{_enum:{SelfReserve:"Null",OtherReserve:"u128"}},AssetRegistrarMetadata:{name:"Vec<u8>",symbol:"Vec<u8>",decimals:"u8",isFrozen:"bool"},VestingBlockNumber:"u32",MultiLocation:"MultiLocationV0"}),A=Object.assign(Object.assign({},I),{JunctionV1:{_enum:{Parachain:"Compact<u32>",AccountId32:"ENUM_AccountId32",AccountIndex64:"ENUM_AccountIndex64",AccountKey20:"ENUM_AccountKey20",PalletInstance:"u8",GeneralIndex:"Compact<u128>",GeneralKey:"Vec<u8>",OnlyChild:"Null",Plurality:"ENUM_Plurality"}},MultiLocation:"MultiLocationV1"}),g=Object.assign(Object.assign({},A),{MoonbaseRuntimeAssetRegistrarMetadata:{name:"Vec<u8>",symbol:"Vec<u8>",decimals:"u8",is_frozen:"bool"},PalletCrowdloanRewardsRewardInfo:{total_reward:"Balance",claimed_reward:"Balance",contributed_relay_addresses:"Vec<RelayChainAccountId>"},ParachainStakingNominator2:{nominations:"Vec<Bond>",revocations:"Vec<AccountId>",total:"Balance",scheduled_revocations_count:"u32",scheduled_revocations_total:"Balance",status:"NominatorStatus"},ParachainStakingExitQ:{candidates:"Vec<AccountId>",nominators_leaving:"Vec<AccountId>",candidate_schedule:"Vec<(AccountId, RoundIndex)>",nominator_schedule:"Vec<(AccountId, Option<AccountId>, RoundIndex)>"},ParachainStakingCollator2:{id:"AccountId",bond:"Balance",nominators:"Vec<AccountId>",top_nominators:"Vec<Bond>",bottom_nominators:"Vec<Bond>",total_counted:"Balance",total_backing:"Balance",state:"CollatorStatus"}});n.moonbeamDefinitions={alias:n.moduleDefinitions,rpc:n.rpcDefinitions,instances:{council:["councilCollective"],technicalCommittee:["techCommitteeCollective"]},types:[{minmax:[0,4],types:a},{minmax:[5,5],types:c},{minmax:[6,19],types:i},{minmax:[19,35],types:l},{minmax:[36,36],types:u},{minmax:[37,42],types:d},{minmax:[43,154],types:m},{minmax:[155,199],types:p},{minmax:[200,399],types:b},{minmax:[400,599],types:y},{minmax:[600,799],types:I},{minmax:[800,899],types:A},{minmax:[900,void 0],types:{ProxyType:{_enum:["Any","NonTransfer","Governance","Staking","CancelProxy","Balances","AuthorMapping"]}}}]},n.moonbeamDefinitionsDeprecated=Object.assign(Object.assign({},n.moonbeamDefinitions),{types:[...n.moonbeamDefinitions.types,{minmax:[900,void 0],types:g}]}),n.typesBundlePre900={spec:{moonbeam:n.moonbeamDefinitions,moonbeamDefinitions:n.moonbeamDefinitions,moonbase:n.moonbeamDefinitions,moonriver:n.moonbeamDefinitions}},n.typesBundleDeprecated={spec:{moonbeam:n.moonbeamDefinitionsDeprecated,moonbeamDefinitions:n.moonbeamDefinitionsDeprecated,moonbase:n.moonbeamDefinitionsDeprecated,moonriver:n.moonbeamDefinitionsDeprecated}}}},n={};function t(a){var o=n[a];if(void 0!==o)return o.exports;var c=n[a]={exports:{}};return e[a].call(c.exports,c,c.exports,t),c.exports}var a={};(()=>{var e=a;Object.defineProperty(e,"__esModule",{value:!0});const n=t(3412);e.default={typesBundle:n.typesBundleDeprecated}})();var o=exports;for(var c in a)o[c]=a[c];a.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();`;
7
-
8
- describe('load', () => {
9
- it('throw error on incorrect format chain types', () => {
10
- expect(() => parseChainTypes(jsChainTypesScript)).toThrow();
11
- });
12
-
13
- it.skip('can load yaml and json format chain types', () => {
14
- expect(parseChainTypes(jsChainTypesScript)).not.toThrow();
15
- });
16
- });
@@ -1,34 +0,0 @@
1
- // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
2
- // SPDX-License-Identifier: GPL-3.0
3
-
4
- import {plainToClass} from 'class-transformer';
5
- import {validateSync} from 'class-validator';
6
- import {ChainTypes} from './models';
7
- import {SubstrateProjectManifestVersioned, VersionedProjectManifest} from './versioned';
8
-
9
- export function parseSubstrateProjectManifest(raw: unknown): SubstrateProjectManifestVersioned {
10
- const projectManifest = new SubstrateProjectManifestVersioned(raw as VersionedProjectManifest);
11
- projectManifest.validate();
12
- return projectManifest;
13
- }
14
-
15
- export function parseChainTypes(raw: unknown): ChainTypes {
16
- const chainTypes = plainToClass(ChainTypes, raw);
17
- if (
18
- !!chainTypes.types ||
19
- !!chainTypes.typesChain ||
20
- !!chainTypes.typesBundle ||
21
- !!chainTypes.typesAlias ||
22
- !!chainTypes.typesSpec
23
- ) {
24
- const errors = validateSync(chainTypes, {whitelist: true, forbidNonWhitelisted: true});
25
- if (errors?.length) {
26
- // TODO: print error details
27
- const errorMsgs = errors.map((e) => e.toString()).join('\n');
28
- throw new Error(`failed to parse chain types.\n${errorMsgs}`);
29
- }
30
- return chainTypes;
31
- } else {
32
- throw new Error(`chainTypes is not valid`);
33
- }
34
- }
@@ -1,180 +0,0 @@
1
- // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
2
- // SPDX-License-Identifier: GPL-3.0
3
-
4
- import {RegisteredTypes, RegistryTypes, OverrideModuleType, OverrideBundleType} from '@polkadot/types/types';
5
- import {BaseDataSource, BlockFilterImpl, ProcessorImpl} from '@subql/common';
6
- import {
7
- SubstrateBlockFilter,
8
- SubstrateBlockHandler,
9
- SubstrateCallFilter,
10
- SubstrateCallHandler,
11
- SubstrateCustomHandler,
12
- SubstrateDatasourceKind,
13
- SubstrateEventFilter,
14
- SubstrateEventHandler,
15
- SubstrateHandlerKind,
16
- SubstrateRuntimeDatasource,
17
- SubstrateRuntimeHandler,
18
- SubstrateCustomDatasource,
19
- } from '@subql/types';
20
- import {BaseMapping, FileReference, Processor} from '@subql/types-core';
21
- import {plainToClass, Transform, Type} from 'class-transformer';
22
- import {
23
- ArrayMaxSize,
24
- IsArray,
25
- IsBoolean,
26
- IsEnum,
27
- IsOptional,
28
- IsString,
29
- IsObject,
30
- ValidateNested,
31
- } from 'class-validator';
32
-
33
- export class BlockFilter extends BlockFilterImpl implements SubstrateBlockFilter {
34
- @IsOptional()
35
- @IsArray()
36
- @ArrayMaxSize(2)
37
- specVersion?: [number, number];
38
- }
39
-
40
- export class EventFilter implements SubstrateEventFilter {
41
- @IsOptional()
42
- @IsString()
43
- module?: string;
44
- @IsOptional()
45
- @IsString()
46
- method?: string;
47
- }
48
-
49
- export class ChainTypes implements RegisteredTypes {
50
- @IsObject()
51
- @IsOptional()
52
- types?: RegistryTypes;
53
- @IsObject()
54
- @IsOptional()
55
- typesAlias?: Record<string, OverrideModuleType>;
56
- @IsObject()
57
- @IsOptional()
58
- typesBundle?: OverrideBundleType;
59
- @IsObject()
60
- @IsOptional()
61
- typesChain?: Record<string, RegistryTypes>;
62
- @IsObject()
63
- @IsOptional()
64
- typesSpec?: Record<string, RegistryTypes>;
65
- }
66
-
67
- export class CallFilter extends EventFilter implements SubstrateCallFilter {
68
- @IsOptional()
69
- @IsBoolean()
70
- success?: boolean;
71
- @IsOptional()
72
- @IsBoolean()
73
- isSigned?: boolean;
74
- }
75
-
76
- export class BlockHandler implements SubstrateBlockHandler {
77
- @IsOptional()
78
- @ValidateNested()
79
- @Type(() => BlockFilter)
80
- filter?: SubstrateBlockFilter;
81
- @IsEnum(SubstrateHandlerKind, {groups: [SubstrateHandlerKind.Block]})
82
- kind!: SubstrateHandlerKind.Block;
83
- @IsString()
84
- handler!: string;
85
- }
86
-
87
- export class CallHandler implements SubstrateCallHandler {
88
- @IsOptional()
89
- @ValidateNested()
90
- @Type(() => CallFilter)
91
- filter?: SubstrateCallFilter;
92
- @IsEnum(SubstrateHandlerKind, {groups: [SubstrateHandlerKind.Call]})
93
- kind!: SubstrateHandlerKind.Call;
94
- @IsString()
95
- handler!: string;
96
- }
97
-
98
- export class EventHandler implements SubstrateEventHandler {
99
- @IsOptional()
100
- @ValidateNested()
101
- @Type(() => EventFilter)
102
- filter?: SubstrateEventFilter;
103
- @IsEnum(SubstrateHandlerKind, {groups: [SubstrateHandlerKind.Event]})
104
- kind!: SubstrateHandlerKind.Event;
105
- @IsString()
106
- handler!: string;
107
- }
108
-
109
- export class CustomHandler implements SubstrateCustomHandler {
110
- @IsString()
111
- kind!: string;
112
- @IsString()
113
- handler!: string;
114
- @IsObject()
115
- @IsOptional()
116
- filter?: Record<string, unknown>;
117
- }
118
-
119
- export class RuntimeMapping implements BaseMapping<SubstrateRuntimeHandler> {
120
- @Transform((params) => {
121
- const handlers: SubstrateRuntimeHandler[] = params.value;
122
- return handlers.map((handler) => {
123
- switch (handler.kind) {
124
- case SubstrateHandlerKind.Event:
125
- return plainToClass(EventHandler, handler);
126
- case SubstrateHandlerKind.Call:
127
- return plainToClass(CallHandler, handler);
128
- case SubstrateHandlerKind.Block:
129
- return plainToClass(BlockHandler, handler);
130
- default:
131
- throw new Error(`handler ${(handler as any).kind} not supported`);
132
- }
133
- });
134
- })
135
- @IsArray()
136
- @ValidateNested()
137
- handlers!: SubstrateRuntimeHandler[];
138
- @IsString()
139
- file!: string;
140
- }
141
-
142
- export class CustomMapping implements BaseMapping<SubstrateCustomHandler> {
143
- @IsArray()
144
- @Type(() => CustomHandler)
145
- @ValidateNested()
146
- handlers!: CustomHandler[];
147
- @IsString()
148
- file!: string;
149
- }
150
-
151
- export class RuntimeDataSourceBase extends BaseDataSource implements SubstrateRuntimeDatasource {
152
- @IsEnum(SubstrateDatasourceKind, {groups: [SubstrateDatasourceKind.Runtime]})
153
- kind!: SubstrateDatasourceKind.Runtime;
154
- @Type(() => RuntimeMapping)
155
- @ValidateNested()
156
- mapping!: RuntimeMapping;
157
- }
158
-
159
- export class FileReferenceImpl implements FileReference {
160
- @IsString()
161
- file!: string;
162
- }
163
-
164
- export class CustomDataSourceBase<K extends string, M extends CustomMapping, O = any>
165
- extends BaseDataSource
166
- implements SubstrateCustomDatasource<K, M, O>
167
- {
168
- @IsString()
169
- kind!: K;
170
- @Type(() => CustomMapping)
171
- @ValidateNested()
172
- mapping!: M;
173
- @Type(() => FileReferenceImpl)
174
- @ValidateNested({each: true})
175
- assets!: Map<string, FileReference>;
176
- @Type(() => ProcessorImpl)
177
- @IsObject()
178
- @ValidateNested()
179
- processor!: Processor<O>;
180
- }