Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
fix: types issue (#287)
Browse files Browse the repository at this point in the history
bump darinwia types to 1.3.0
  • Loading branch information
sxlwar authored Oct 22, 2021
1 parent 8a95f91 commit 1aac287
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@polkadot/wasm-crypto": "^1.4.1",
"babel-core": "^7.0.0-bridge.0",
"typescript": "^3.8.3",
"@darwinia/types": "1.2.50"
"@darwinia/types": "1.3.0"
},
"scripts": {
"analyze": "yarn run build && cd packages/apps && yarn run source-map-explorer build/main.*.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.11.2",
"@darwinia/types-known": "1.2.50",
"@darwinia/types-known": "1.3.0",
"@polkadot/types": "1.35.0-beta.19",
"@polkadot/util": "^3.5.1",
"@polkadot/util-crypto": "^3.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/page-settings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@darwinia/types-known": "1.2.50",
"@darwinia/types-known": "1.3.0",
"@polkadot/apps-config": "0.42.0-beta.100",
"@polkadot/react-components": "0.42.0-beta.100",
"@polkadot/react-query": "0.42.0-beta.100",
Expand Down
2 changes: 1 addition & 1 deletion packages/page-staking-darwinia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@darwinia/types": "1.2.50",
"@darwinia/types": "1.3.0",
"@polkadot/app-explorer": "0.42.0-beta.100",
"@polkadot/react-components-darwinia": "0.42.0-beta.100",
"@polkadot/react-query": "0.42.0-beta.100"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.9.6",
"@darwinia/types-known": "1.2.50",
"@darwinia/types-known": "1.3.0",
"@polkadot/api": "1.35.0-beta.19",
"@polkadot/extension-dapp": "^0.25.0-beta.4",
"rxjs-compat": "^6.6.2"
Expand Down
23 changes: 22 additions & 1 deletion packages/types/src/create/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ const mappings: Mapper[] = [
// <T::Balance as HasCompact>
cleanupCompact(),
// Change BoundedVec<Type, Size> to Vec<Type>
removeBounded(),
removeExtensions('Bounded', true),
// Change WeakVec<Type> to Vec<Type>
removeExtensions('Weak', false),
// Remove all the trait prefixes
removeTraits(),
// remove PairOf<T> -> (T, T)
Expand Down Expand Up @@ -220,3 +222,22 @@ export default function sanitize (value: String | string, options?: SanitizeOpti
fn(result, options), value.toString()
).trim();
}

// remove the Bounded* or Weak* wrappers
export function removeExtensions (type: string, isSized: boolean): Mapper {
return (value: string) =>
BOUNDED.reduce((value, tag) =>
replaceTagWith(value, `${type}${tag}<`, (inner: string): string => {
const parts = inner
.split(',')
.map((s) => s.trim())
.filter((s) => s);

if (isSized) {
parts.pop();
}

return `${tag}<${parts.join(',')}>`;
}), value
);
}
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1408,24 +1408,24 @@ __metadata:
languageName: node
linkType: hard

"@darwinia/types-known@npm:1.2.50, @darwinia/types-known@npm:^1.2.50":
version: 1.2.50
resolution: "@darwinia/types-known@npm:1.2.50"
"@darwinia/types-known@npm:1.3.0, @darwinia/types-known@npm:^1.3.0":
version: 1.3.0
resolution: "@darwinia/types-known@npm:1.3.0"
dependencies:
"@babel/runtime": ^7.9.6
"@polkadot/types": 4.0.4-5
"@polkadot/util": 6.0.5
bn.js: ^5.1.2
checksum: df6b6b3ba099d80537d008664ccadcf7e8ea51446712a886ff919420689e7c50695846098e6348b375bb43b79c87202f3e49ac1f8af655f4562083d452bdefcc
checksum: 2166fc71531a70653ec73dd1841412544685181718f41afe5ba63579655d6704ec0f1c0ae32c14f4e5df4b0ed47cd924a021692c33bed8f4719ecf73bc678c9d
languageName: node
linkType: hard

"@darwinia/types@npm:1.2.50":
version: 1.2.50
resolution: "@darwinia/types@npm:1.2.50"
"@darwinia/types@npm:1.3.0":
version: 1.3.0
resolution: "@darwinia/types@npm:1.3.0"
dependencies:
"@darwinia/types-known": ^1.2.50
checksum: 7df1e56c688a7fc7ba07671a0ab7a144d74f732295335b68fe88ae316a6851ff07cae4190fcc1fe75812838e35a984a6da424750d19655cdeecd0a2d5d0bbe03
"@darwinia/types-known": ^1.3.0
checksum: da28edce2f9a62bb76c18c9c9d91da88f0433281cb94c53a4538950bcf6f76c4796dcbf8b5c5f751fae2d43a454a0e436b216d9f677f79bac27e1ce916d65c9b
languageName: node
linkType: hard

Expand Down Expand Up @@ -3264,7 +3264,7 @@ __metadata:
resolution: "@polkadot/app-settings@workspace:packages/page-settings"
dependencies:
"@babel/runtime": ^7.9.6
"@darwinia/types-known": 1.2.50
"@darwinia/types-known": 1.3.0
"@polkadot/apps-config": 0.42.0-beta.100
"@polkadot/react-components": 0.42.0-beta.100
"@polkadot/react-query": 0.42.0-beta.100
Expand All @@ -3286,7 +3286,7 @@ __metadata:
resolution: "@polkadot/app-staking-darwinia@workspace:packages/page-staking-darwinia"
dependencies:
"@babel/runtime": ^7.9.6
"@darwinia/types": 1.2.50
"@darwinia/types": 1.3.0
"@polkadot/app-explorer": 0.42.0-beta.100
"@polkadot/react-components-darwinia": 0.42.0-beta.100
"@polkadot/react-query": 0.42.0-beta.100
Expand Down Expand Up @@ -3535,7 +3535,7 @@ __metadata:
resolution: "@polkadot/metadata@workspace:packages/metadata"
dependencies:
"@babel/runtime": ^7.11.2
"@darwinia/types-known": 1.2.50
"@darwinia/types-known": 1.3.0
"@polkadot/keyring": ^3.5.1
"@polkadot/types": 1.35.0-beta.19
"@polkadot/util": ^3.5.1
Expand All @@ -3549,7 +3549,7 @@ __metadata:
resolution: "@polkadot/react-api@workspace:packages/react-api"
dependencies:
"@babel/runtime": ^7.9.6
"@darwinia/types-known": 1.2.50
"@darwinia/types-known": 1.3.0
"@polkadot/api": 1.35.0-beta.19
"@polkadot/extension-dapp": ^0.25.0-beta.4
rxjs-compat: ^6.6.2
Expand Down

0 comments on commit 1aac287

Please sign in to comment.