Skip to content

Commit

Permalink
zksend sdk fix network detection (#20268)
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?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
pchrysochoidis authored Nov 14, 2024
1 parent 28e184a commit 1765780
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-timers-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/zksend': patch
---

fix zksend link network detection
13 changes: 4 additions & 9 deletions sdk/zksend/src/links/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,16 @@ export class ZkSendLink {
) {
const parsed = new URL(url);
const isContractLink = parsed.hash.startsWith('#$');
const parsedNetwork = parsed.searchParams.get('network') === 'testnet' ? 'testnet' : 'mainnet';
const network = options.network ?? parsedNetwork;

let link: ZkSendLink;
if (isContractLink) {
const keypair = Ed25519Keypair.fromSecretKey(fromBase64(parsed.hash.slice(2)));
link = new ZkSendLink({
...options,
keypair,
network:
options.network ?? parsed.searchParams.get('network') === 'testnet'
? 'testnet'
: 'mainnet',
network,
host: `${parsed.protocol}//${parsed.host}`,
path: parsed.pathname,
isContractLink: true,
Expand All @@ -143,14 +142,10 @@ export class ZkSendLink {
const keypair = Ed25519Keypair.fromSecretKey(
fromBase64(isContractLink ? parsed.hash.slice(2) : parsed.hash.slice(1)),
);

link = new ZkSendLink({
...options,
keypair,
network:
options.network ?? parsed.searchParams.get('network') === 'testnet'
? 'testnet'
: 'mainnet',
network,
host: `${parsed.protocol}//${parsed.host}`,
path: parsed.pathname,
isContractLink: false,
Expand Down

0 comments on commit 1765780

Please sign in to comment.