-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from CityOfZion/CU-86a5jgc40
CU-86a5jgc40-BS Swap - Add refund in SwapStatus type and separate get…
- Loading branch information
Showing
8 changed files
with
106 additions
and
73 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
common/changes/@cityofzion/blockchain-service/CU-86a5jgc40_2024-11-11-17-59.json
This file contains 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,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@cityofzion/blockchain-service", | ||
"comment": "Add refund in SwapStatus type and separate getStatus method", | ||
"type": "minor" | ||
} | ||
], | ||
"packageName": "@cityofzion/blockchain-service" | ||
} |
10 changes: 10 additions & 0 deletions
10
common/changes/@cityofzion/bs-swap/CU-86a5jgc40_2024-11-11-17-59.json
This file contains 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,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@cityofzion/bs-swap", | ||
"comment": "Add refund in SwapStatus type and separate getStatus method", | ||
"type": "minor" | ||
} | ||
], | ||
"packageName": "@cityofzion/bs-swap" | ||
} |
This file contains 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 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 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 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,34 @@ | ||
import { SwapServiceHelper, SwapServiceStatusResponse } from '@cityofzion/blockchain-service' | ||
import { SimpleSwapApi } from '../apis/SimpleSwapApi' | ||
|
||
export class SimpleSwapServiceHelper<BSName extends string = string> implements SwapServiceHelper { | ||
#api: SimpleSwapApi<BSName> | ||
|
||
constructor(apiKey: string) { | ||
this.#api = new SimpleSwapApi(apiKey) | ||
} | ||
|
||
async getStatus(id: string): Promise<SwapServiceStatusResponse> { | ||
const response = await this.#api.getExchange(id) | ||
|
||
const statusBySimpleSwapStatus: Record<string, SwapServiceStatusResponse['status']> = { | ||
waiting: 'confirming', | ||
confirming: 'confirming', | ||
exchanging: 'exchanging', | ||
sending: 'exchanging', | ||
verifying: 'exchanging', | ||
finished: 'finished', | ||
expired: 'failed', | ||
failed: 'failed', | ||
refunded: 'refunded', | ||
} | ||
|
||
const status = statusBySimpleSwapStatus[response.status] | ||
|
||
return { | ||
status, | ||
txFrom: response.txFrom, | ||
txTo: response.txTo, | ||
} | ||
} | ||
} |
This file contains 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 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