Skip to content
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
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stacks-mesh-api",
"version": "0.4.2",
"version": "0.4.3",
"private": true,
"description": "Mesh API implementation for Stacks blockchain - monorepo",
"workspaces": [
Expand Down
2 changes: 1 addition & 1 deletion packages/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3
info:
title: Stacks Mesh API
description: A Mesh API (formerly Rosetta API) implementation for the Stacks blockchain
version: 0.4.2
version: 0.4.3
components:
schemas: {}
paths:
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stacks/mesh-api",
"version": "0.4.2",
"version": "0.4.3",
"description": "Mesh API implementation for Stacks blockchain",
"main": "dist/index.js",
"type": "module",
Expand Down
31 changes: 31 additions & 0 deletions packages/api/tests/construction/combine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,37 @@ describe('/construction/combine', () => {
assert.ok(body.signed_transaction.length >= unsignedTx.length);
});

test('combines unsigned transaction when signing payload address is omitted', async () => {
// Sign the sighash offline
const signature = addHexPrefix(signWithKey(SENDER_PRIVATE_KEY, removeHexPrefix(sighash)));

const res = await post(fastify, '/construction/combine', {
network_identifier: NETWORK_IDENTIFIER,
unsigned_transaction: unsignedTx,
signatures: [
{
signing_payload: {
hex_bytes: sighash,
account_identifier: {
address: senderAddress,
},
signature_type: 'ecdsa_recovery',
},
public_key: {
hex_bytes: senderPublicKey,
curve_type: 'secp256k1',
},
signature_type: 'ecdsa_recovery',
hex_bytes: signature,
},
],
});
assert.equal(res.statusCode, 200);
const body = JSON.parse(res.body);
assert.ok(body.signed_transaction);
assert.ok(body.signed_transaction.length >= unsignedTx.length);
});

test('rejects when no signatures are provided', async () => {
const res = await post(fastify, '/construction/combine', {
network_identifier: NETWORK_IDENTIFIER,
Expand Down
2 changes: 1 addition & 1 deletion packages/schemas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stacks/mesh-schemas",
"version": "0.4.2",
"version": "0.4.3",
"description": "Mesh API schemas for Stacks blockchain transactions and blocks",
"type": "module",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/schemas/src/schemas/entities/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ export const SubAccountIdentifierSchema = Type.Object({
});
export type SubAccountIdentifier = Static<typeof SubAccountIdentifierSchema>;

export const AccountIndentifierSchema = Type.Object({
export const AccountIdentifierSchema = Type.Object({
address: StacksPrincipalSchema,
sub_account: Type.Optional(SubAccountIdentifierSchema),
});
export type AccountIdentifier = Static<typeof AccountIndentifierSchema>;
export type AccountIdentifier = Static<typeof AccountIdentifierSchema>;

export const BlockIdentifierSchema = Type.Object({
index: Type.Integer({ minimum: 1 }),
Expand Down
14 changes: 7 additions & 7 deletions packages/schemas/src/schemas/entities/construction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Static, Type } from '@sinclair/typebox';
import { AccountIndentifierSchema, AmountSchema } from '../index.js';
import { AccountIdentifierSchema, AmountSchema, StacksPrincipalSchema } from '../index.js';
import { HexStringSchema, Nullable, OperationIdentifierSchema } from './common.js';

export const PublicKeySchema = Type.Object({
Expand All @@ -9,8 +9,8 @@ export const PublicKeySchema = Type.Object({
export type PublicKey = Static<typeof PublicKeySchema>;

export const SigningPayloadSchema = Type.Object({
address: Type.String(),
account_identifier: AccountIndentifierSchema,
address: Type.Optional(StacksPrincipalSchema),
Comment thread
rafa-stacks marked this conversation as resolved.
account_identifier: AccountIdentifierSchema,
hex_bytes: HexStringSchema,
signature_type: Type.Literal('ecdsa_recovery'),
});
Expand Down Expand Up @@ -86,15 +86,15 @@ export type ConstructionMetadata = Static<typeof ConstructionMetadataSchema>;
export const ConstructionFeeOperationSchema = Type.Object({
operation_identifier: OperationIdentifierSchema,
type: Type.Literal('fee'),
account: AccountIndentifierSchema,
account: AccountIdentifierSchema,
amount: AmountSchema,
});
export type ConstructionFeeOperation = Static<typeof ConstructionFeeOperationSchema>;

export const ConstructionTokenTransferOperationSchema = Type.Object({
operation_identifier: OperationIdentifierSchema,
type: Type.Literal('token_transfer'),
account: AccountIndentifierSchema,
account: AccountIdentifierSchema,
amount: AmountSchema,
metadata: Type.Optional(Type.Object({ memo: Nullable(Type.String()) })),
});
Expand All @@ -105,7 +105,7 @@ export type ConstructionTokenTransferOperation = Static<
export const ConstructionContractCallOperationSchema = Type.Object({
operation_identifier: OperationIdentifierSchema,
type: Type.Literal('contract_call'),
account: AccountIndentifierSchema,
account: AccountIdentifierSchema,
metadata: Type.Object({
contract_identifier: Type.String(),
function_name: Type.String(),
Expand All @@ -119,7 +119,7 @@ export type ConstructionContractCallOperation = Static<
export const ConstructionContractDeployOperationSchema = Type.Object({
operation_identifier: OperationIdentifierSchema,
type: Type.Literal('contract_deploy'),
account: AccountIndentifierSchema,
account: AccountIdentifierSchema,
metadata: Type.Object({
contract_name: Type.String(),
clarity_version: Type.Optional(Type.Integer()),
Expand Down
4 changes: 2 additions & 2 deletions packages/schemas/src/schemas/entities/operations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Static, Type } from '@sinclair/typebox';
import {
AccountIndentifierSchema,
AccountIdentifierSchema,
DecodedClarityValueSchema,
Nullable,
OperationIdentifierSchema,
Expand Down Expand Up @@ -35,7 +35,7 @@ const BaseOperationSchema = Type.Object({
const BaseAccountOperationSchema = Type.Composite([
BaseOperationSchema,
Type.Object({
account: AccountIndentifierSchema,
account: AccountIdentifierSchema,
}),
]);

Expand Down
6 changes: 3 additions & 3 deletions packages/schemas/src/schemas/requests/account.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { BlockIdentifierSchema, AccountIndentifierSchema } from "../entities/common.js";
import { BlockIdentifierSchema, AccountIdentifierSchema } from "../entities/common.js";
import { NetworkIdentifierSchema } from "../entities/network.js";
import { Static, Type } from "@sinclair/typebox";
import { CurrencySchema } from "../entities/operations.js";

export const AccountBalanceRequestSchema = Type.Object({
network_identifier: NetworkIdentifierSchema,
account_identifier: AccountIndentifierSchema,
account_identifier: AccountIdentifierSchema,
block_identifier: Type.Optional(Type.Partial(BlockIdentifierSchema)),
currencies: Type.Optional(Type.Array(CurrencySchema)),
});
export type AccountBalanceRequest = Static<typeof AccountBalanceRequestSchema>;

export const AccountCoinsRequestSchema = Type.Object({
network_identifier: NetworkIdentifierSchema,
account_identifier: AccountIndentifierSchema,
account_identifier: AccountIdentifierSchema,
include_mempool: Type.Boolean(),
currencies: Type.Optional(Type.Array(CurrencySchema)),
});
Expand Down
8 changes: 4 additions & 4 deletions packages/schemas/src/schemas/responses/construction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Static, Type } from '@sinclair/typebox';
import { AccountIndentifierSchema, HexStringSchema } from '../entities/common.js';
import { AccountIdentifierSchema, HexStringSchema } from '../entities/common.js';
import { AmountSchema, OperationSchema } from '../entities/operations.js';
import { TransactionIdentifierSchema } from '../entities/common.js';
import {
Expand All @@ -10,13 +10,13 @@ import {

export const ConstructionDeriveResponseSchema = Type.Object({
address: Type.Optional(Type.String()),
account_identifier: Type.Optional(AccountIndentifierSchema),
account_identifier: Type.Optional(AccountIdentifierSchema),
});
export type ConstructionDeriveResponse = Static<typeof ConstructionDeriveResponseSchema>;

export const ConstructionPreprocessResponseSchema = Type.Object({
options: Type.Optional(ConstructionOptionsSchema),
required_public_keys: Type.Optional(Type.Array(AccountIndentifierSchema)),
required_public_keys: Type.Optional(Type.Array(AccountIdentifierSchema)),
});
export type ConstructionPreprocessResponse = Static<typeof ConstructionPreprocessResponseSchema>;

Expand All @@ -40,7 +40,7 @@ export type ConstructionCombineResponse = Static<typeof ConstructionCombineRespo
export const ConstructionParseResponseSchema = Type.Object({
operations: Type.Array(OperationSchema),
signers: Type.Optional(Type.Array(Type.String())),
account_identifier_signers: Type.Optional(Type.Array(AccountIndentifierSchema)),
account_identifier_signers: Type.Optional(Type.Array(AccountIdentifierSchema)),
metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
});
export type ConstructionParseResponse = Static<typeof ConstructionParseResponseSchema>;
Expand Down
Loading