-
Notifications
You must be signed in to change notification settings - Fork 0
Realign #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Realign #485
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,37 @@ | ||
| import { encode, Encoding } from '@aeternity/aepp-sdk'; | ||
|
|
||
| const hexToBytes = (hex: string): Uint8Array => { | ||
| const normalized = hex.startsWith('0x') ? hex.slice(2) : hex; | ||
| if (!/^[0-9a-fA-F]+$/.test(normalized) || normalized.length % 2 !== 0) { | ||
| throw new Error('Secret key has invalid hex format'); | ||
| } | ||
|
|
||
| const bytes = new Uint8Array(normalized.length / 2); | ||
| for (let i = 0; i < normalized.length; i += 2) { | ||
| bytes[i / 2] = parseInt(normalized.slice(i, i + 2), 16); | ||
| } | ||
| return bytes; | ||
| }; | ||
|
|
||
| /** | ||
| * aepp-sdk v14 expects `sk_` encoded 32-byte secrets. | ||
| * Older persisted values can be raw hex or a longer keypair payload. | ||
| */ | ||
| export const normalizeSecretKey = (rawSecret: string): `sk_${string}` => { | ||
| const secret = rawSecret.trim(); | ||
| if (!secret) { | ||
| throw new Error('Secret key is missing'); | ||
| } | ||
|
|
||
| if (secret.startsWith('sk_')) return secret as `sk_${string}`; | ||
|
|
||
| const secretBytes = hexToBytes(secret); | ||
| if (secretBytes.length < 32) { | ||
| throw new Error('Secret key must contain at least 32 bytes'); | ||
| } | ||
|
|
||
| return encode( | ||
| secretBytes.subarray(0, 32), | ||
| Encoding.AccountSecretKey, | ||
| ) as `sk_${string}`; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claimed invitation detail parsing may lose data
Medium Severity
The claim call changed from
affiliationTreasury.redeemInvitationCode(invitationCode, activeAccount)(wrapper passing two values) toaffiliationTreasury.contract.redeem_invitation_code(activeAccount, { onAccount: account })(direct call with one contract argument). The transaction-parsing code inuseInvitations.tsstill readstx.tx?.arguments?.[1]?.valueto extract the claimer address, based on the old two-argument layout. With only one on-chain argument now,arguments[1]will beundefined, causing the code to fall back to a baretrueinstead of returning detailedClaimedInfo(claimedBy,claimedAt,claimTxHash).Additional Locations (1)
src/features/trending/hooks/useInvitations.ts#L349-L354