Skip to content

Commit

Permalink
feat(2847512320): adjust numeric types (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgluskin-starkware authored Sep 5, 2022
1 parent 4489660 commit 37550b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ _Example for a DepositRequest_
```ts
const request = {
txId: 10234993,
amount: 4029557120079369747,
amount: "4029557120079369747",
starkKey: "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
tokenId: "0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",
vaultId: 1654615998
Expand Down
15 changes: 8 additions & 7 deletions src/lib/gateway/gateway-request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
FeeInfoExchangeRequest,
FeeInfoUserRequest,
NumericSequence,
OrderRequest,
Signature
} from './gateway-types';
Expand All @@ -14,11 +15,11 @@ type GatewayRequest =
| ConditionalTransferRequest;

interface Request {
txId: number;
txId: NumericSequence;
}

interface WithVault {
vaultId: number;
vaultId: NumericSequence;
}

interface WithStarkKey {
Expand All @@ -27,7 +28,7 @@ interface WithStarkKey {

interface WithAmount {
tokenId: string;
amount: number;
amount: string;
}

interface TransactionRequest
Expand All @@ -43,13 +44,13 @@ interface FalseFullWithdrawalRequest extends Request, WithVault {
}

interface TransferRequest extends Request {
amount: number;
nonce: number;
amount: string;
nonce: NumericSequence;
senderPublicKey: string;
senderVaultId: number;
senderVaultId: NumericSequence;
token: string;
receiverPublicKey: string;
receiverVaultId: number;
receiverVaultId: NumericSequence;
expirationTimestamp: number;
signature: Signature;
feeInfoUser?: FeeInfoUserRequest;
Expand Down
19 changes: 12 additions & 7 deletions src/lib/gateway/gateway-types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// Represents a numeric (only) sequence to hold numbers
// that cannot fit into the built-in JS number type
type NumericSequence = number | string;

interface OrderRequest {
orderType: OrderTypeObsolete;
nonce: number;
amountSell: number;
amountBuy: number;
nonce: NumericSequence;
amountSell: string;
amountBuy: string;
tokenSell: string;
tokenBuy: string;
vaultIdSell: number;
vaultIdBuy: number;
vaultIdSell: NumericSequence;
vaultIdBuy: NumericSequence;
expirationTimestamp: number;
feeInfo?: FeeInfoUserRequest;
}
Expand All @@ -18,13 +22,13 @@ interface Signature {

interface FeeInfoUserRequest {
feeLimit: number;
sourceVaultId: number;
sourceVaultId: NumericSequence;
tokenId: string;
}

interface FeeInfoExchangeRequest {
destinationStarkKey: string;
destinationVaultId: number;
destinationVaultId: NumericSequence;
feeTaken: number;
}

Expand All @@ -38,5 +42,6 @@ export {
Signature,
FeeInfoUserRequest,
FeeInfoExchangeRequest,
NumericSequence,
OrderTypeObsolete
};
2 changes: 1 addition & 1 deletion test/gateway.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Gateway', () => {
let starkExAPI, error;
const vaultId = 1;
const txId = 1;
const amount = 1;
const amount = '1';
const starkKey = '0x2';
const tokenId = '0x1';
const nonce = 2;
Expand Down

0 comments on commit 37550b7

Please sign in to comment.