-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Disallow unregistered classes in JSON RPC interface and match by…
… name (#1820) Prevents from accidentally passing an unregistered class in the autogenerated JSON RPC client and server. Picks the converter to use for serialisation based on constructor name if function equality match fails (since constructor name match may fail in minimised browser bundles). We were bit by this when the `PrivateKey` class was registered in the client, but due to a duplicated module, the `PrivateKey` class registered was not the same as the one passed as an argument. This caused the object not to be properly serialised, which due to #1819 was not picked up on the server side, and caused all sort of issues. Fixes #1826 --------- Co-authored-by: spypsy <spypsy@outlook.com>
- Loading branch information
1 parent
d299fc6
commit 35b8170
Showing
5 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Test class for testing string converter. | ||
*/ | ||
export class ToStringClass { | ||
constructor(/** A value */ public readonly x: string, /** Another value */ public readonly y: string) {} | ||
|
||
toString(): string { | ||
return [this.x, this.y].join('-'); | ||
} | ||
|
||
static fromString(value: string) { | ||
const [x, y] = value.split('-'); | ||
return new ToStringClass(x, y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Test class for testing string converter. | ||
*/ | ||
export class ToStringClass { | ||
constructor(/** A value */ public readonly x: string, /** Another value */ public readonly y: string) {} | ||
|
||
toString(): string { | ||
return [this.x, this.y].join('-'); | ||
} | ||
|
||
static fromString(value: string) { | ||
const [x, y] = value.split('-'); | ||
return new ToStringClass(x, y); | ||
} | ||
} |