Skip to content

Commit

Permalink
v0.6.0 Remove registration signing (#23)
Browse files Browse the repository at this point in the history
* Signable -> StarkSignable

* v0.6.0 Remove signable registration
  • Loading branch information
Kenadia committed Jan 6, 2021
1 parent 8d124e4 commit 09aa70c
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 83 deletions.
35 changes: 0 additions & 35 deletions __tests__/signable/registration.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion 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": "@dydxprotocol/starkex-lib",
"version": "0.5.0",
"version": "0.6.0",
"description": "Cryptographic functions for use with StarkEx",
"main": "build/src/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/signable/api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import BN from 'bn.js';

import { hexToBn } from '../lib/util';
import { ApiRequestParams } from '../types';
import { Signable } from './signable';
import { StarkSignable } from './stark-signable';

/**
* Wrapper object to hash, sign, and verify an API request.
*/
export class SignableApiRequest extends Signable<ApiRequestParams> {
export class SignableApiRequest extends StarkSignable<ApiRequestParams> {

public constructor(
apiRequest: ApiRequestParams,
Expand Down
1 change: 0 additions & 1 deletion src/signable/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { SignableApiRequest } from './api-request';
export { SignableOraclePrice } from './oracle-price';
export { SignableOrder } from './order';
export { SignableRegistration } from './registration';
export { SignableWithdrawal } from './withdrawal';
4 changes: 2 additions & 2 deletions src/signable/oracle-price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
OraclePriceWithAssetId,
} from '../types';
import { ORACLE_PRICE_FIELD_BIT_LENGTHS } from './constants';
import { Signable } from './signable';
import { StarkSignable } from './stark-signable';

/**
* Wrapper object to hash, sign, and verify an oracle price.
*/
export class SignableOraclePrice extends Signable<OraclePriceWithAssetId> {
export class SignableOraclePrice extends StarkSignable<OraclePriceWithAssetId> {

static fromPrice = SignableOraclePrice.fromPriceWithAssetName; // Alias.

Expand Down
4 changes: 2 additions & 2 deletions src/signable/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import {
import {
ORDER_FIELD_BIT_LENGTHS,
} from './constants';
import { Signable } from './signable';
import { StarkSignable } from './stark-signable';

const LIMIT_ORDER_WITH_FEES = 3;
const ORDER_PADDING_BITS = 17;

/**
* Wrapper object to convert an order, and hash, sign, and verify its signature.
*/
export class SignableOrder extends Signable<StarkwareOrder> {
export class SignableOrder extends StarkSignable<StarkwareOrder> {

static fromOrder = SignableOrder.fromOrderWithClientId; // Alias.

Expand Down
28 changes: 0 additions & 28 deletions src/signable/registration.ts

This file was deleted.

7 changes: 5 additions & 2 deletions src/signable/signable.ts → src/signable/stark-signable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { bnToHex32 } from '../lib/util';
import { KeyPair } from '../types';

/**
* Base class for a Starkware signable message.
* Base class for a STARK key signable message.
*/
export abstract class Signable<T> {
export abstract class StarkSignable<T> {
protected readonly message: T;

private _hashBN: BN | null = null;
Expand All @@ -27,6 +27,9 @@ export abstract class Signable<T> {
this.message = message;
}

/**
* Return the message hash as a hex string, no 0x prefix.
*/
get hash(): string {
return this.hashBN.toString(16);
}
Expand Down
4 changes: 2 additions & 2 deletions src/signable/withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
WithdrawalWithClientId,
} from '../types';
import { WITHDRAWAL_FIELD_BIT_LENGTHS } from './constants';
import { Signable } from './signable';
import { StarkSignable } from './stark-signable';

const COLLATERAL_ASSET_ID_BN = hexToBn(COLLATERAL_ASSET_ID);
const WITHDRAWAL_PREFIX = 6;
Expand All @@ -26,7 +26,7 @@ const WITHDRAWAL_PADDING_BITS = 49;
/**
* Wrapper object to convert a withdrawal, and hash, sign, and verify its signature.
*/
export class SignableWithdrawal extends Signable<StarkwareWithdrawal> {
export class SignableWithdrawal extends StarkSignable<StarkwareWithdrawal> {

static fromWithdrawal = SignableWithdrawal.fromWithdrawalWithClientId; // Alias.

Expand Down
7 changes: 0 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ export interface ApiRequestParams {
body: string;
}

// ============ Regsistration Parameters ============

export interface RegistrationParams {
ethereumAddress: string;
starkKey: string;
}

// ============ Oracle Price Parameters ============

export interface OraclePriceWithAssetName {
Expand Down

0 comments on commit 09aa70c

Please sign in to comment.