Skip to content
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

[Stacks 2.1] Support Stacks 2.1 in @stacks/stacking (PoX-2) #1347

Closed
4 tasks done
zone117x opened this issue Aug 29, 2022 · 0 comments · Fixed by #1354
Closed
4 tasks done

[Stacks 2.1] Support Stacks 2.1 in @stacks/stacking (PoX-2) #1347

zone117x opened this issue Aug 29, 2022 · 0 comments · Fixed by #1354
Assignees
Milestone

Comments

@zone117x
Copy link
Member

zone117x commented Aug 29, 2022

A PoX-2 contract will be deployed after the Stacks 2.1 hardfork goes live. Several new functions will be available:

It probably makes sense to create a new set of sister function calls for PoX-2, and detect if the new functions should be used via an RPC call to determine if PoX-2 is live. The library needs to detect if Period 3 has activated -- this is after the 2.1 fork, and after PoX cycle (N+1), see https://github.com/stacksgov/sips/blob/c0fb33e0fc2b62e8e6d4ed85fb4b4aa289bb6042/sips/sip-015/sip-015-network-upgrade.md#specification

It may be possible to detect if PoX-2 is ready by checking if GET /v2/pox returns {"contract_id":"ST000000000000000000002AMW42H.pox-2"}, but that appears to be unimplemented as of opening this issue: stacks-network/stacks-core#3262

In the meantime, something like this should work:

async function isPoX2Ready(): Promise<boolean> {
  const req = await fetch(`/v2/data_var/ST000000000000000000002AMW42H/pox-2/configured?proof=0`);
  const body = await req.text();
  if (req.ok) {
    return JSON.parse(body)['data'] === '0x03'; // Clarity boolean-true
  } else if (req.status === 404 && body === 'Data var not found') {
    return false;
  } else {
    throw new Error(`Unexpected response: ${req.status} - ${body}`);
  }
}
@janniks janniks self-assigned this Aug 29, 2022
@janniks janniks added the P1 label Aug 29, 2022
@janniks janniks removed their assignment Aug 29, 2022
@janniks janniks mentioned this issue Sep 13, 2022
2 tasks
@janniks janniks added this to the Q3-2022 milestone Sep 26, 2022
@saralab saralab modified the milestones: Q3-2022, Q4-2022 Sep 30, 2022
@janniks janniks closed this as completed Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants