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

nakamoto #1653

Merged
merged 7 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ jobs:
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- uses: actions/checkout@v3
if: github.event_name == 'workflow_dispatch'
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
Expand All @@ -59,3 +62,9 @@ jobs:
with:
header: "> This PR was published to npm with the version `${{ steps.published-version.outputs.version }}`\n> e.g. `npm install @stacks/common@${{ steps.published-version.outputs.version }} --save-exact`"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
git reset --hard
npx lerna publish --canary --preid $BRANCH --dist-tag $BRANCH --no-verify-access --no-push --no-git-tag-version --yes
if: ${{ (github.head_ref || github.ref_name) == 'nakamoto' || (github.head_ref || github.ref_name) == 'next' }}
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions packages/common/src/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ export function readUInt16BE(source: Uint8Array, offset: number): number {
}

/** @ignore */
export function writeUInt16BE(source: Uint8Array, value: number, offset: number): void {
source[offset + 0] = value >>> 8;
source[offset + 1] = value >>> 0;
export function writeUInt16BE(destination: Uint8Array, value: number, offset = 0): Uint8Array {
destination[offset + 0] = value >>> 8;
destination[offset + 1] = value >>> 0;
return destination;
}

// The following methods are based on `microsoft/vscode` implementation
Expand All @@ -49,8 +50,9 @@ export function readUInt8(source: Uint8Array, offset: number): number {
}

/** @ignore */
export function writeUInt8(destination: Uint8Array, value: number, offset: number): void {
export function writeUInt8(destination: Uint8Array, value: number, offset = 0): Uint8Array {
destination[offset] = value;
return destination;
}

/** @ignore */
Expand All @@ -59,10 +61,11 @@ export function readUInt16LE(source: Uint8Array, offset: number): number {
}

/** @ignore */
export function writeUInt16LE(destination: Uint8Array, value: number, offset: number): void {
export function writeUInt16LE(destination: Uint8Array, value: number, offset = 0): Uint8Array {
destination[offset + 0] = value & 0b1111_1111;
value >>>= 8;
destination[offset + 1] = value & 0b1111_1111;
return destination;
}

/** @ignore */
Expand All @@ -76,14 +79,15 @@ export function readUInt32BE(source: Uint8Array, offset: number): number {
}

/** @ignore */
export function writeUInt32BE(destination: Uint8Array, value: number, offset: number): void {
export function writeUInt32BE(destination: Uint8Array, value: number, offset = 0): Uint8Array {
destination[offset + 3] = value;
value >>>= 8;
destination[offset + 2] = value;
value >>>= 8;
destination[offset + 1] = value;
value >>>= 8;
destination[offset] = value;
return destination;
}

/** @ignore */
Expand All @@ -97,12 +101,13 @@ export function readUInt32LE(source: Uint8Array, offset: number): number {
}

/** @ignore */
export function writeUInt32LE(destination: Uint8Array, value: number, offset: number): void {
export function writeUInt32LE(destination: Uint8Array, value: number, offset = 0): Uint8Array {
destination[offset + 0] = value & 0b1111_1111;
value >>>= 8;
destination[offset + 1] = value & 0b1111_1111;
value >>>= 8;
destination[offset + 2] = value & 0b1111_1111;
value >>>= 8;
destination[offset + 3] = value & 0b1111_1111;
return destination;
}
16 changes: 15 additions & 1 deletion packages/stacking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,27 @@ const privateKey = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5
// block height at which to stack
const burnBlockHeight = 2000;

// signer key
const signerPrivateKey = makeRandomPrivKey();
const signerKey = getPublicKeyFromPrivate(signerPrivateKey.data);

// Refer to initialization section to create client instance
const signerSignature = client.signPoxSignature({
topic: 'stack-stx',
rewardCycle: await client.getPoxInfo().reward_cycle_id,
poxAddress,
period: cycles,
signerPrivateKey,
});

const stackingResults = await client.stack({
amountMicroStx,
poxAddress,
cycles,
privateKey,
burnBlockHeight,
signerKey,
signerSignature,
});

// {
Expand Down Expand Up @@ -521,7 +535,7 @@ const delegetateCommitResponse = await poolClient.stackAggregationCommitIndexed(

#### Increase existing commitment

The result of this commit transaction will contain the index of the pools reward set entry.
Increase partially stacked STX via the index of the reward set entry.

```typescript
// reward cycle id to commit to
Expand Down
1 change: 1 addition & 0 deletions packages/stacking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"typecheck:watch": "npm run typecheck -- --watch"
},
"dependencies": {
"@noble/hashes": "1.1.5",
"@scure/base": "1.1.1",
"@stacks/common": "^6.10.0",
"@stacks/encryption": "^6.12.1",
Expand Down
Loading
Loading