Skip to content

Commit

Permalink
feat: update crypto and fiat amount to number (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinenerio authored Jan 31, 2025
1 parent 1de7826 commit aba5f06
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 30 deletions.
5 changes: 0 additions & 5 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var crypto = require('crypto');
var jose = require('jose');
var axios = require('axios');
var nacl = require('tweetnacl');
Expand Down Expand Up @@ -2077,10 +2076,6 @@ class BrijPartnerClient {
}
return decrypted;
}
async generateHash(value) {
const serializedData = value.encode(value).finish(); //TODO double check
return crypto.createHash("sha256").update(Buffer.from(serializedData)).digest("hex");
}
createUserOnRampMessage({ cryptoAmount, cryptoCurrency, fiatAmount, fiatCurrency, }) {
return `${cryptoAmount}|${cryptoCurrency}|${fiatAmount}|${fiatCurrency}`;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.cjs.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ type Order = {
userPublicKey: string;
comment: string;
type: "ON_RAMP" | "OFF_RAMP";
cryptoAmount: string;
cryptoAmount: number;
cryptoCurrency: string;
fiatAmount: string;
fiatAmount: number;
fiatCurrency: string;
bankName: string;
bankAccount: string;
Expand Down Expand Up @@ -131,7 +131,6 @@ declare class BrijPartnerClient {
getUserInfo(publicKey: string): Promise<any>;
getUserSecretKey(publicKey: string): Promise<string>;
private decryptData;
private generateHash;
private createUserOnRampMessage;
private createUserOffRampMessage;
private createPartnerOnRampMessage;
Expand Down
5 changes: 0 additions & 5 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brij-partner-sdk",
"version": "0.5.1",
"version": "0.6.0",
"description": "",
"main": "dist/index.cjs",
"module": "dist/index.js",
Expand Down
24 changes: 10 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ export type Order = {
userPublicKey: string;
comment: string;
type: "ON_RAMP" | "OFF_RAMP";
cryptoAmount: string;
cryptoAmount: number;
cryptoCurrency: string;
fiatAmount: string;
fiatAmount: number;
fiatCurrency: string;
bankName: string;
bankAccount: string;
Expand Down Expand Up @@ -578,20 +578,16 @@ export class BrijPartnerClient {

return decrypted;
}
private async generateHash(value: MessageFns<any>): Promise<string> {
const serializedData = value.encode(value).finish(); //TODO double check
return createHash("sha256").update(Buffer.from(serializedData)).digest("hex");
}

private createUserOnRampMessage({
cryptoAmount,
cryptoCurrency,
fiatAmount,
fiatCurrency,
}: {
cryptoAmount: string;
cryptoAmount: number;
cryptoCurrency: string;
fiatAmount: string;
fiatAmount: number;
fiatCurrency: string;
}): string {
return `${cryptoAmount}|${cryptoCurrency}|${fiatAmount}|${fiatCurrency}`;
Expand All @@ -605,9 +601,9 @@ export class BrijPartnerClient {
bankName,
bankAccount,
}: {
cryptoAmount: string;
cryptoAmount: number;
cryptoCurrency: string;
fiatAmount: string;
fiatAmount: number;
fiatCurrency: string;
bankName: string;
bankAccount: string;
Expand All @@ -623,9 +619,9 @@ export class BrijPartnerClient {
bankName,
bankAccount,
}: {
cryptoAmount: string;
cryptoAmount: number;
cryptoCurrency: string;
fiatAmount: string;
fiatAmount: number;
fiatCurrency: string;
bankName: string;
bankAccount: string;
Expand All @@ -640,9 +636,9 @@ export class BrijPartnerClient {
fiatCurrency,
cryptoWalletAddress,
}: {
cryptoAmount: string;
cryptoAmount: number;
cryptoCurrency: string;
fiatAmount: string;
fiatAmount: number;
fiatCurrency: string;
cryptoWalletAddress: string;
}): string {
Expand Down

0 comments on commit aba5f06

Please sign in to comment.