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
2 changes: 1 addition & 1 deletion examples/statement-playground/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const stmt1: Statement = {
}

// SIGN AND SUBMIT STATEMENT
const signed1 = alice.sign(stmt1)
const signed1 = await alice.sign(stmt1)
await sdk.submit(signed1)

console.log(
Expand Down
4 changes: 2 additions & 2 deletions examples/statement-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"private": true,
"dependencies": {
"@polkadot-api/sdk-statement": "workspace:*",
"@polkadot-api/substrate-bindings": "^0.16.3",
"@polkadot-api/substrate-bindings": "^0.16.5",
"@polkadot-api/substrate-client": "^0.4.7",
"@polkadot-api/utils": "^0.2.0",
"@polkadot-api/ws-provider": "^0.6.1",
"@polkadot-api/ws-provider": "^0.7.4",
"@scure/sr25519": "^0.3.0"
},
"devDependencies": {
Expand Down
12 changes: 11 additions & 1 deletion packages/sdk-statement/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

## Unreleased

## 0.1.0 2025-09-29
## 0.2.0 - 2025-11-26

### Changed

- `StatementSigner.sign` is now async

### Removed

- Remove unwanted exports

## 0.1.0 - 2025-09-29

### Added

Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-statement/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot-api/sdk-statement",
"version": "0.1.0",
"version": "0.2.0",
"sideEffects": false,
"author": "Carlo Sala (https://github.com/carlosala)",
"repository": {
Expand Down Expand Up @@ -42,7 +42,7 @@
},
"license": "MIT",
"dependencies": {
"@polkadot-api/substrate-bindings": "^0.16.3",
"@polkadot-api/substrate-bindings": "^0.16.5",
"@polkadot-api/utils": "^0.2.0"
}
}
2 changes: 1 addition & 1 deletion packages/sdk-statement/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./codec"
export * from "./statement-sdk"
export * from "./signer"
export * from "./utils"
export { stringToTopic } from "./utils"
6 changes: 3 additions & 3 deletions packages/sdk-statement/src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { SignedStatement, Statement, statementCodec } from "./codec"
export const getStatementSigner = (
publicKey: Uint8Array,
type: "ed25519" | "sr25519" | "ecdsa",
signFn: (payload: Uint8Array) => Uint8Array,
signFn: (payload: Uint8Array) => Promise<Uint8Array> | Uint8Array,
) => ({
publicKey,
sign: (stmt: Statement): SignedStatement => {
sign: async (stmt: Statement): Promise<SignedStatement> => {
if (stmt.proof) throw new Error("Statement already signed")
const encoded = statementCodec.enc(stmt)
const compactLen = compact.enc(compact.dec(encoded)).length
const signature = signFn(encoded.slice(compactLen))
const signature = await signFn(encoded.slice(compactLen))
const result = statementCodec.dec(encoded)
result.proof = Enum(type, {
signature: Binary.fromBytes(signature),
Expand Down
Loading