Skip to content

Commit

Permalink
remove noble secp256k1 as dep in signature type def (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin authored Sep 19, 2023
1 parent d1497a2 commit 38a54fb
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 50 deletions.
6 changes: 3 additions & 3 deletions connect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wormhole-foundation/connect-sdk",
"version": "0.1.3-beta.2",
"version": "0.1.3-beta.4",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
Expand Down Expand Up @@ -58,7 +58,7 @@
},
"dependencies": {
"axios": "^1.4.0",
"@wormhole-foundation/sdk-base": "0.1.3-beta.2",
"@wormhole-foundation/sdk-definitions": "0.1.3-beta.2"
"@wormhole-foundation/sdk-base": "0.1.3-beta.4",
"@wormhole-foundation/sdk-definitions": "0.1.3-beta.4"
}
}
2 changes: 1 addition & 1 deletion connect/src/wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Contracts,
TxHash,
WormholeMessageId,
isTokenId,
} from '@wormhole-foundation/sdk-definitions';
import axios, { AxiosResponse } from 'axios';

Expand All @@ -31,7 +32,6 @@ import { CONFIG } from './constants';
import { TokenTransfer } from './protocols/tokenTransfer';
import { CCTPTransfer } from './protocols/cctpTransfer';
import { TransactionStatus } from './api';
import { isTokenId } from '@wormhole-foundation/sdk-definitions/src';

export class Wormhole {
protected _platforms: Map<PlatformName, Platform<PlatformName>>;
Expand Down
2 changes: 1 addition & 1 deletion core/base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wormhole-foundation/sdk-base",
"version": "0.1.3-beta.2",
"version": "0.1.3-beta.4",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
Expand Down
15 changes: 7 additions & 8 deletions core/definitions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wormhole-foundation/sdk-definitions",
"version": "0.1.3-beta.2",
"version": "0.1.3-beta.4",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
Expand All @@ -14,22 +14,21 @@
},
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types":"./dist/esm/index.d.ts",
"types": "./dist/esm/index.d.ts",
"files": [
"dist/**/*",
"src/**/*"
],
"scripts": {
"test": "jest --config ../../jest.config.ts __tests__/*.ts",
"build:cjs":"tsc -p ./tsconfig.cjs.json",
"build:esm":"tsc -p ./tsconfig.esm.json",
"build":"npm run build:cjs && npm run build:esm",
"rebuild":"npm run clean && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc -p ./tsconfig.cjs.json",
"build:esm": "tsc -p ./tsconfig.esm.json",
"build": "npm run build:cjs && npm run build:esm",
"rebuild": "npm run clean && npm run build:cjs && npm run build:esm",
"clean": "rm -rf ./dist && rm -f ./*.tsbuildinfo"
},
"dependencies": {
"@wormhole-foundation/sdk-base": "*",
"@noble/hashes": "^1.3.1",
"@noble/secp256k1": "^2.0.0"
"@wormhole-foundation/sdk-base": "*"
}
}
2 changes: 1 addition & 1 deletion core/definitions/src/layout-items/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export const signatureItem = {
return new Signature(sig.r, sig.s, sig.v);
},
from: (val: Signature): Uint8Array =>
serializeLayout(signatureLayout, { r: val.r, s: val.s, v: val.recovery }),
serializeLayout(signatureLayout, { r: val.r, s: val.s, v: val.v }),
} as const satisfies CustomConversion<Uint8Array, Signature>,
} as const satisfies Omit<FixedSizeBytesLayoutItem, "name">;
22 changes: 6 additions & 16 deletions core/definitions/src/signature.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
//TODO this should get properly wrapped and get its own interface so we don't expose implementation
// internals and can swap out the implementation if we choose to later. Maybe also rename
// recovery to v then (this seems to be the convention at least in EVM land)

import { Signature as SignatureOptionalRecovery } from "@noble/secp256k1";

export class Signature extends SignatureOptionalRecovery {
constructor(
readonly r: bigint,
readonly s: bigint,
readonly recovery: number
) {
super(r, s, recovery);
}
// Signature represents the secp256k1 signature of a Guardian
export class Signature {
constructor(readonly r: bigint, readonly s: bigint, readonly v: number) {}

toUint8Array(): Uint8Array {
const buff = new Uint8Array(65);
buff.set(this.toCompactRawBytes());
buff.set([this.recovery], 64);
buff.set(Buffer.from(this.r.toString(16), "hex"));
buff.set(Buffer.from(this.s.toString(16), "hex"), 32);
buff.set([this.v], 64);
return buff;
}

Expand Down
25 changes: 7 additions & 18 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 platforms/evm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wormhole-foundation/connect-sdk-evm",
"version": "0.1.3-beta.2",
"version": "0.1.3-beta.4",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
Expand Down
2 changes: 1 addition & 1 deletion platforms/solana/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wormhole-foundation/connect-sdk-solana",
"version": "0.1.3-beta.2",
"version": "0.1.3-beta.4",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
Expand Down

0 comments on commit 38a54fb

Please sign in to comment.