Skip to content

Commit

Permalink
[zksend] handle spaces in hash (MystenLabs#15688)
Browse files Browse the repository at this point in the history
## Description 

Describe the changes or additions included in this PR.

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
hayes-mysten authored Jan 12, 2024
1 parent e87d997 commit c859f41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-taxis-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/zksend': patch
---

Handle base64 with spaces in hash
7 changes: 6 additions & 1 deletion sdk/zksend/src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ export class ZkSendHost {
const parsed = new URL(url);

const urlHashData = parsed.hash
? Object.fromEntries(new URLSearchParams(parsed.hash.slice(1)))
? Object.fromEntries(
[...new URLSearchParams(parsed.hash.slice(1))].map(([key, value]) => [
key,
value.replace(/ /g, '+'),
]),
)
: {};

const request = parse(ZkSendRequest, {
Expand Down
2 changes: 1 addition & 1 deletion sdk/zksend/src/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class ZkSendLinkBuilder {
} else {
const coins = (await this.#getCoinsByType(coinType)).map((coin) => coin.coinObjectId);
const merged =
coins.length > 0 ? txb.mergeCoins(coins[0], coins.slice(1)) : txb.object(coins[0]);
coins.length > 1 ? txb.mergeCoins(coins[0], coins.slice(1)) : txb.object(coins[0]);
const [split] = txb.splitCoins(merged, [amount]);
objectsToTransfer.push(split);
}
Expand Down

0 comments on commit c859f41

Please sign in to comment.