From 89586bc93422a4f9fd2e0237b9071f3f11cf4e53 Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Wed, 11 Nov 2020 21:43:19 +0100 Subject: [PATCH] feat: use STX locked_address from https://github.com/blockstack/stacks-blockchain/pull/2050 --- docs/openapi.yaml | 92 +++++++++++++-------------- follower.Dockerfile | 1 - src/event-stream/core-node-message.ts | 2 + src/event-stream/event-server.ts | 7 +- 4 files changed, 49 insertions(+), 53 deletions(-) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 1fb7285bc1..821deabd96 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1155,56 +1155,56 @@ paths: schema: $ref: ./api/rosetta/rosetta-construction-submit-request.schema.json -/rosetta/v1/construction/payloads: - post: - tags: - - Rosetta - summary: Generate an Unsigned Transaction and Signing Payloads - operationId: rosetta_construction_payloads - description: Generate and unsigned transaction from operations and metadata - responses: - 200: - description: Success - content: - application/json: - schema: - $ref: ./api/rosetta/rosetta-construction-payloads-response.schema.json - 400: - description: Error + /rosetta/v1/construction/payloads: + post: + tags: + - Rosetta + summary: Generate an Unsigned Transaction and Signing Payloads + operationId: rosetta_construction_payloads + description: Generate and unsigned transaction from operations and metadata + responses: + 200: + description: Success + content: + application/json: + schema: + $ref: ./api/rosetta/rosetta-construction-payloads-response.schema.json + 400: + description: Error + content: + application/json: + schema: + $ref: ./entities/rosetta/rosetta-error.schema.json + requestBody: + required: true content: application/json: schema: - $ref: ./entities/rosetta/rosetta-error.schema.json - requestBody: - required: true - content: - application/json: - schema: - $ref: ./api/rosetta/rosetta-construction-payloads-request.schema.json + $ref: ./api/rosetta/rosetta-construction-payloads-request.schema.json -/rosetta/v1/construction/combine: - post: - tags: - - Rosetta - summary: Create Network Transaction from Signatures - operationId: rosetta_construction_combine - description: Take unsigned transaction and signature, combine both and return signed transaction - responses: - 200: - description: Success - content: - application/json: - schema: - $ref: ./api/rosetta/rosetta-construction-combine-response.schema.json - 400: - description: Error + /rosetta/v1/construction/combine: + post: + tags: + - Rosetta + summary: Create Network Transaction from Signatures + operationId: rosetta_construction_combine + description: Take unsigned transaction and signature, combine both and return signed transaction + responses: + 200: + description: Success + content: + application/json: + schema: + $ref: ./api/rosetta/rosetta-construction-combine-response.schema.json + 400: + description: Error + content: + application/json: + schema: + $ref: ./entities/rosetta/rosetta-error.schema.json + requestBody: + required: true content: application/json: schema: - $ref: ./entities/rosetta/rosetta-error.schema.json - requestBody: - required: true - content: - application/json: - schema: - $ref: ./api/rosetta/rosetta-construction-combine-request.schema.json + $ref: ./api/rosetta/rosetta-construction-combine-request.schema.json diff --git a/follower.Dockerfile b/follower.Dockerfile index 8dc7ba12bf..da0d1f95be 100644 --- a/follower.Dockerfile +++ b/follower.Dockerfile @@ -4,7 +4,6 @@ WORKDIR /app COPY . . RUN apk add --no-cache --virtual .build-deps alpine-sdk python git openjdk8-jre RUN echo "GIT_TAG=$(git tag --points-at HEAD)" >> .env -# RUN npm config set unsafe-perm true && npm install --unsafe-perm && npm run build --unsafe-perm && npm prune --production RUN npm config set unsafe-perm true && npm install && npm run build && npm prune --production ### Fetch stacks-node binary diff --git a/src/event-stream/core-node-message.ts b/src/event-stream/core-node-message.ts index e99c1a64c6..2c425cedb2 100644 --- a/src/event-stream/core-node-message.ts +++ b/src/event-stream/core-node-message.ts @@ -67,6 +67,8 @@ export interface StxLockEvent extends CoreNodeEventBase { locked_amount: string; /** String quoted base10 integer. */ unlock_height: string; + /** STX principal associated with the locked tokens. */ + locked_address: string; }; } diff --git a/src/event-stream/event-server.ts b/src/event-stream/event-server.ts index aa54d0ecb0..6c97629524 100644 --- a/src/event-stream/event-server.ts +++ b/src/event-stream/event-server.ts @@ -145,17 +145,12 @@ async function handleClientMessage(msg: CoreNodeMessage, db: DataStore): Promise break; } case CoreNodeEventType.StxLockEvent: { - // TODO: THIS IS NOT SAFE. Core needs to add `locked_address` to the event payload. - const sender = assertNotNullish( - parsedMsg.parsed_transactions.find(t => t.core_tx.txid === event.txid), - () => `Failed to match StxLockEvent txid ${event.txid}` - ).sender_address; const entry: DbStxLockEvent = { ...dbEvent, event_type: DbEventTypeId.StxLock, locked_amount: BigInt(event.stx_lock_event.locked_amount), unlock_height: BigInt(event.stx_lock_event.unlock_height), - locked_address: sender, + locked_address: event.stx_lock_event.locked_address, }; dbTx.stxLockEvents.push(entry); break;