Skip to content

Commit

Permalink
fix: Replace legacy method (#381)
Browse files Browse the repository at this point in the history
* fix: Replace legacy method

* Create cool-shoes-visit.md

---------

Co-authored-by: rrr523 <[email protected]>
  • Loading branch information
aiden-cao and rrr523 authored Oct 30, 2023
1 parent a53deb4 commit c399ff9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-shoes-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bnb-chain/greenfield-js-sdk": patch
---

fix: Replace legacy method, Some third-party plug-ins (e.g. wallet guard) will automatically convert deprecated methods and are not compatible with the return value of deprecated methods. https://github.com/wallet-guard/wallet-guard-extension/blob/221ad3eb329ad7681b16a37c7ddfaf173dba6e7f/src/injected/injectWalletGuard.tsx#L49-L62
12 changes: 5 additions & 7 deletions packages/js-sdk/src/clients/spclient/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ const signMessagePersonalAPI = async (
message: Uint8Array,
address: string,
): Promise<string> => {
return provider.send('personal_sign', [hexlify(message), address]).then(
(sign: string) => sign,
(err: Error) => {
throw err;
},
);
return provider.request({
method: 'personal_sign',
params: [hexlify(message), address],
});
};

const generateSeed = async (
Expand All @@ -36,7 +34,7 @@ const generateSeed = async (
) => {
const signedBytes = typeof message === 'string' ? toUtf8Bytes(message) : arrayify(message);
const res = (await signMessagePersonalAPI(provider, signedBytes, address)) as any;
const seed = arrayify(res?.result);
const seed = arrayify(res);

return { seed };
};
Expand Down

0 comments on commit c399ff9

Please sign in to comment.