Skip to content

Commit

Permalink
Merge pull request #70 from mysteriumnetwork/remove-reg-req-fees
Browse files Browse the repository at this point in the history
Remove reg req fees
  • Loading branch information
tadaskay authored Feb 4, 2021
2 parents c8e54f8 + 8a64716 commit 3eca87d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mysterium-vpn-js",
"version": "8.1.0",
"version": "9.0.0",
"description": "Javascript SDK for Mysterium node",
"keywords": [
"mysterium",
Expand Down
3 changes: 2 additions & 1 deletion src/fmt/money-formater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import { Money, Currency } from '../proposal/payment-method'
import { Currency } from '../proposal/payment-method'
import { Money } from '../payment'

export interface DisplayMoneyOptions {
showCurrency?: boolean
Expand Down
1 change: 0 additions & 1 deletion src/identity/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { validateMultiple } from '../fmt/validation'
export interface IdentityRegisterRequest {
stake?: number
beneficiary?: string
fee?: number
referralToken?: string
}

Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export { ServiceLocation } from './proposal/service-location'
export {
PaymentMethod,
PaymentMethodType,
Money,
Currency,
pricePerMinute,
pricePerHour,
pricePerGiB,
} from './proposal/payment-method'

Expand Down Expand Up @@ -78,7 +78,12 @@ export { TequilapiError, AxiosError } from './tequilapi-error'
export { MMNReport, MMNApiKeyResponse, MMNReportResponse } from './mmn/mmn'
export { Pageable } from './common/pageable'

export { PaymentOrderResponse, PaymentOrderRequest, PaymentOrderOptionsResponse } from './payments'
export {
Money,
PaymentOrderResponse,
PaymentOrderRequest,
PaymentOrderOptionsResponse,
} from './payment'
export { ReferralTokenResponse } from './referral'

export default tequilapi
5 changes: 5 additions & 0 deletions src/payments/index.ts → src/payment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ export interface PaymentOrderOptionsResponse {
minimum: number
suggested: number[]
}

export interface Money {
amount: number
currency: string
}
14 changes: 9 additions & 5 deletions src/proposal/payment-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Money } from '../payment'

export interface PaymentMethod {
type: PaymentMethodType
Expand All @@ -19,11 +20,6 @@ export enum PaymentMethodType {
Unsupported = 'UNSUPPORTED',
}

export interface Money {
amount: number
currency: string
}

export enum Currency {
MYST = 'MYST',
MYSTTestToken = 'MYSTT',
Expand All @@ -39,6 +35,14 @@ export const pricePerMinute = (pm?: PaymentMethod): Money => {
}
}

export const pricePerHour = (p?: PaymentMethod): Money => {
const price = pricePerMinute(p)
return {
currency: price.currency,
amount: price.amount * 60,
}
}

const bytesInGiB = 1024 * 1024 * 1024

export const pricePerGiB = (pm?: PaymentMethod): Money => {
Expand Down
13 changes: 12 additions & 1 deletion src/tequilapi-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ import {
} from './transactor/settlement'
import { IdentityCurrentRequest } from './identity/selection'
import { AuthRequest, AuthResponse, ChangePasswordRequest } from './auth/auth'
import { PaymentOrderOptionsResponse, PaymentOrderRequest, PaymentOrderResponse } from './payments'
import {
Money,
PaymentOrderOptionsResponse,
PaymentOrderRequest,
PaymentOrderResponse,
} from './payment'
import { ReferralTokenResponse } from './referral'

export const TEQUILAPI_URL = 'http://127.0.0.1:4050'
Expand Down Expand Up @@ -144,6 +149,7 @@ export interface TequilapiClient {
getPaymentOrder(identity: string, orderId: number): Promise<PaymentOrderResponse>
getPaymentOrderOptions(): Promise<PaymentOrderOptionsResponse>
getPaymentOrderCurrencies(): Promise<string[]>
exchangeRate(quoteCurrency?: string): Promise<Money>

getReferralToken(identity: string): Promise<ReferralTokenResponse>
}
Expand Down Expand Up @@ -539,4 +545,9 @@ export class HttpTequilapiClient implements TequilapiClient {
public async getReferralToken(identity: string): Promise<ReferralTokenResponse> {
return this.http.get(`/identities/${identity}/referral`)
}

public async exchangeRate(quoteCurrency = 'usd'): Promise<Money> {
const baseCurrency = 'myst'
return this.http.get(`/exchange/${baseCurrency}/${quoteCurrency}`)
}
}
11 changes: 10 additions & 1 deletion src/test-utils/empty-tequilapi-client-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ import {
import { IdentityCurrentRequest } from '../identity/selection'
import { IdentityBeneficiaryResponse } from '../identity/beneficiary'
import { AuthRequest, AuthResponse, ChangePasswordRequest } from '../auth/auth'
import { PaymentOrderOptionsResponse, PaymentOrderRequest, PaymentOrderResponse } from '../payments'
import {
Money,
PaymentOrderOptionsResponse,
PaymentOrderRequest,
PaymentOrderResponse,
} from '../payment'
import { Terms, TermsRequest } from '../daemon/terms'
import { ReferralTokenResponse } from '../referral'

Expand Down Expand Up @@ -298,4 +303,8 @@ export class EmptyTequilapiClientMock implements TequilapiClient {
public async getReferralToken(identity: string): Promise<ReferralTokenResponse> {
throw Error('Not implemented')
}

public async exchangeRate(quoteCurrency?: string): Promise<Money> {
throw Error('Not implemented')
}
}

0 comments on commit 3eca87d

Please sign in to comment.