Skip to content

Commit

Permalink
feat: Export encodePath
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed May 28, 2024
1 parent 9e3e74e commit 433273d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-ads-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bnb-chain/bsc-cross-greenfield-sdk': patch
---

feat: export `encodePath`
6 changes: 2 additions & 4 deletions packages/js-sdk/src/clients/spclient/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthType, ReqMeta } from '@/types/auth';
import { arrayify, hexlify, joinSignature } from '@ethersproject/bytes';
import { hexlify, joinSignature } from '@ethersproject/bytes';
import { SigningKey } from '@ethersproject/signing-key';
import { toUtf8Bytes } from '@ethersproject/strings';
import { ed25519 } from '@noble/curves/ed25519';
Expand Down Expand Up @@ -59,8 +59,7 @@ export const getCanonicalRequest = (reqMeta: Partial<ReqMeta>, reqHeaders: Heade
};

export const getAuthorization = (canonicalRequest: string, authType: AuthType) => {
// eslint-disable-next-line no-console
console.log('canonicalRequest', canonicalRequest);
// console.log('canonicalRequest', canonicalRequest);

const unsignedMsg = getMsgToSign(utf8ToBytes(canonicalRequest));
let authorization = '';
Expand Down Expand Up @@ -172,7 +171,6 @@ export const getMsgToSign = (unsignedBytes: Uint8Array): Uint8Array => {
};

export const encodePath = (pathName: string) => {
debugger;
const reservedNames = /^[a-zA-Z0-9-_.~/]+$/;
if (reservedNames.test(pathName)) {
return pathName;
Expand Down
3 changes: 3 additions & 0 deletions packages/js-sdk/src/utils/encoding.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { encodePath } from '../clients/spclient/auth';

const toHex = (char = '') => {
return char.charCodeAt(0).toString(16);
};
Expand Down Expand Up @@ -54,4 +56,5 @@ export {
encodeObjectToHexString,
decodeObjectFromHexString,
encodeToHexString,
encodePath,
};

0 comments on commit 433273d

Please sign in to comment.