-
Notifications
You must be signed in to change notification settings - Fork 7
Feature support num payment #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0bdafe6
feat(dia-backend-store.service): add store service to support NUM pay…
vincent10400094 5a1fbb1
add(order-detail-dialog.component): create dialog component to show o…
vincent10400094 51a0414
feat(actions.page): support netowrk app payment using backend store s…
vincent10400094 9bb3ee9
feat(actions.page.ts): add error handling for insufficent fund
vincent10400094 e1e3547
change(actions.page): adjust error message for insufficient NUM token…
vincent10400094 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/app/shared/dia-backend/store/dia-backend-store.service.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { TestBed } from '@angular/core/testing'; | ||
| import { SharedTestingModule } from '../../shared-testing.module'; | ||
| import { DiaBackendStoreService } from './dia-backend-store.service'; | ||
|
|
||
| describe('DiaBackendStoreService', () => { | ||
| let service: DiaBackendStoreService; | ||
|
|
||
| beforeEach(() => { | ||
| TestBed.configureTestingModule({ | ||
| imports: [SharedTestingModule], | ||
| }); | ||
| service = TestBed.inject(DiaBackendStoreService); | ||
| }); | ||
|
|
||
| it('should be created', () => { | ||
| expect(service).toBeTruthy(); | ||
| }); | ||
| }); |
63 changes: 63 additions & 0 deletions
63
src/app/shared/dia-backend/store/dia-backend-store.service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { HttpClient } from '@angular/common/http'; | ||
| import { Injectable } from '@angular/core'; | ||
| import { defer } from 'rxjs'; | ||
| import { concatMap } from 'rxjs/operators'; | ||
| import { DiaBackendAuthService } from '../auth/dia-backend-auth.service'; | ||
| import { BASE_URL } from '../secret'; | ||
|
|
||
| @Injectable({ | ||
| providedIn: 'root', | ||
| }) | ||
| export class DiaBackendStoreService { | ||
| constructor( | ||
| private readonly httpClient: HttpClient, | ||
| private readonly authService: DiaBackendAuthService | ||
| ) {} | ||
|
|
||
| createNetworkAppOrder(networkApp: string, actionArgs: any) { | ||
| return defer(() => this.authService.getAuthHeadersWithApiKey()).pipe( | ||
| concatMap(headers => { | ||
| return this.httpClient.post<NetworkAppOrderStatus>( | ||
| `${BASE_URL}/api/v3/store/network-app-orders/`, | ||
| { | ||
| network_app: networkApp, | ||
| action_args: actionArgs, | ||
| }, | ||
| { headers } | ||
| ); | ||
| }) | ||
| ); | ||
| } | ||
|
|
||
| confirmNetworkAppOrder(id: string) { | ||
| return defer(() => this.authService.getAuthHeadersWithApiKey()).pipe( | ||
| concatMap(headers => { | ||
| return this.httpClient.post<NetworkAppOrderStatus>( | ||
| `${BASE_URL}/api/v3/store/network-app-orders/${id}/confirm/`, | ||
| {}, | ||
| { headers } | ||
| ); | ||
| }) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export interface NetworkAppOrderStatus { | ||
| id: string; | ||
| status: 'completed' | 'canceled' | 'pending'; | ||
| network_app: string; | ||
| action: string; | ||
| action_args: Record<string, unknown>; | ||
| price: string; | ||
| fee: string | null; | ||
| total_cost: string; | ||
| quantity: number; | ||
| fund_crypto_transaction_id: string; | ||
| fund_tx_hash: string; | ||
| payment_crypto_transaction_id: string; | ||
| payment_tx_hash: string; | ||
| workflow_id: string; | ||
| owner: string; | ||
| created_at: string; | ||
| expired_at: string; | ||
| } |
33 changes: 33 additions & 0 deletions
33
src/app/shared/order-detail-dialog/order-detail-dialog.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <div *transloco="let t"> | ||
| <h2 mat-dialog-title>{{ t('payment.confirmPayment') }}</h2> | ||
| <ion-row style="border-bottom: groove"> | ||
| <ion-col> | ||
| <ion-label>{{ t('payment.price') }}</ion-label> | ||
| </ion-col> | ||
| <ion-col align="end"> | ||
| <ion-label>{{ orderStatus.price | number: '1.2-2' }} NUM</ion-label> | ||
| </ion-col> | ||
| </ion-row> | ||
| <ion-row style="border-bottom: groove"> | ||
| <ion-col> | ||
| <ion-label>{{ t('payment.fee') }}</ion-label> | ||
| </ion-col> | ||
| <ion-col align="end"> | ||
| <ion-label>{{ orderStatus.fee | number: '1.2-2' }} NUM</ion-label> | ||
| </ion-col> | ||
| </ion-row> | ||
| <ion-row> | ||
| <ion-col> | ||
| <ion-label>{{ t('payment.totalCost') }}</ion-label> | ||
| </ion-col> | ||
| <ion-col align="end"> | ||
| <ion-label>{{ orderStatus.total_cost | number: '1.2-2' }} NUM</ion-label> | ||
| </ion-col> | ||
| </ion-row> | ||
| <mat-dialog-actions align="end"> | ||
| <button mat-button (click)="cancel()">{{ t('cancel') }}</button> | ||
| <button mat-button color="primary" (click)="ok()"> | ||
| {{ t('ok') }} | ||
| </button> | ||
| </mat-dialog-actions> | ||
| </div> |
Empty file.
30 changes: 30 additions & 0 deletions
30
src/app/shared/order-detail-dialog/order-detail-dialog.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
| import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
| import { SharedTestingModule } from '../../shared/shared-testing.module'; | ||
| import { OrderDetailDialogComponent } from './order-detail-dialog.component'; | ||
|
|
||
| describe('ActionsDialogComponent', () => { | ||
| let component: OrderDetailDialogComponent; | ||
| let fixture: ComponentFixture<OrderDetailDialogComponent>; | ||
|
|
||
| beforeEach( | ||
| waitForAsync(() => { | ||
| TestBed.configureTestingModule({ | ||
| declarations: [OrderDetailDialogComponent], | ||
| imports: [SharedTestingModule], | ||
| providers: [ | ||
| { provide: MatDialogRef, useValue: {} }, | ||
| { provide: MAT_DIALOG_DATA, useValue: {} }, | ||
| ], | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(OrderDetailDialogComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }) | ||
| ); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); |
27 changes: 27 additions & 0 deletions
27
src/app/shared/order-detail-dialog/order-detail-dialog.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { Component, Inject } from '@angular/core'; | ||
| import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
| import { NetworkAppOrderStatus } from '../dia-backend/store/dia-backend-store.service'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-order-detail-dialog', | ||
| templateUrl: './order-detail-dialog.component.html', | ||
| styleUrls: ['./order-detail-dialog.component.scss'], | ||
| }) | ||
| export class OrderDetailDialogComponent { | ||
| readonly orderStatus: NetworkAppOrderStatus; | ||
|
|
||
| constructor( | ||
| private readonly dialogRef: MatDialogRef<OrderDetailDialogComponent>, | ||
| @Inject(MAT_DIALOG_DATA) public data: NetworkAppOrderStatus | ||
| ) { | ||
| this.orderStatus = data; | ||
| } | ||
|
|
||
| ok() { | ||
| this.dialogRef.close(this.orderStatus.id); | ||
| } | ||
|
|
||
| cancel() { | ||
| this.dialogRef.close(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.