Skip to content

Commit

Permalink
feat: add serializeNep413
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny0529 committed Oct 6, 2023
1 parent babb301 commit 978a3aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export {
isCurrentBrowserSupported,
verifyFullKeyBelongsToUser,
verifySignature,
serializeNep413,
} from "./lib/helpers";

export { translate, allowOnlyLanguage } from "./lib/translate/translate";
1 change: 1 addition & 0 deletions packages/core/src/lib/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./waitFor";
export * from "./getActiveAccount";
export * from "./detect-browser";
export * from "./verify-signature/verify-signature";
export * from "./verify-signature/payload";
8 changes: 8 additions & 0 deletions packages/core/src/lib/helpers/verify-signature/payload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { SignMessageParams } from "../../wallet";
import { serialize } from "borsh";

export class Payload {
tag: number;
Expand Down Expand Up @@ -41,3 +42,10 @@ export const payloadSchema = new Map([
},
],
]);

export const serializeNep413 = (
signMessageParams: SignMessageParams
): Buffer => {
const payload = new Payload({ ...signMessageParams });
return Buffer.from(serialize(payloadSchema, payload));
};

0 comments on commit 978a3aa

Please sign in to comment.