Skip to content

Commit

Permalink
fix: dot sigs
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed May 1, 2024
1 parent a94dc2d commit abd4cf2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MiddlewareFunction } from "@enkryptcom/types";
import SubstrateProvider from "..";
import { ProviderRPCRequest } from "@/types/provider";
import { polkadotEncodeAddress } from "@enkryptcom/utils";
import { polkadotEncodeAddress, utf8ToHex } from "@enkryptcom/utils";
import { SignerPayloadRaw } from "@polkadot/types/types";
import { getCustomError } from "@/libs/error";
import { WindowPromise } from "@/libs/window-promise";
Expand All @@ -13,11 +13,16 @@ const method: MiddlewareFunction = function (
): void {
if (payload.method !== "dot_signer_signRaw") return next();
else {
console.log(payload);
if (!payload.params?.length)
return res(getCustomError("Missing Params: signer_signPayload"));
const reqPayload = payload.params[0] as SignerPayloadRaw;
if (reqPayload.type !== "bytes" && reqPayload.type !== "payload")
return res(getCustomError("type is not bytes: signer_signRaw"));
const data =
reqPayload.type === "payload"
? utf8ToHex(reqPayload.data)
: reqPayload.data;
this.KeyRing.getAccount(polkadotEncodeAddress(reqPayload.address)).then(
(account) => {
const windowPromise = new WindowPromise();
Expand All @@ -26,7 +31,7 @@ const method: MiddlewareFunction = function (
this.getUIPath(this.UIRoutes.dotSignMessage.path),
JSON.stringify({
...payload,
params: [reqPayload.data, account],
params: [data, account],
}),
true
)
Expand Down

1 comment on commit abd4cf2

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.