Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
wax
Commits
ef862af4
Commit
ef862af4
authored
7 months ago
by
Bartek Wrona
Browse files
Options
Downloads
Patches
Plain Diff
hiveToHbd added to wax TS interface
parent
250cf894
No related branches found
No related tags found
1 merge request
!203
Support for Hive -> HBD conversion
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ts/wasm/lib/detailed/base_api.ts
+17
-0
17 additions, 0 deletions
ts/wasm/lib/detailed/base_api.ts
ts/wasm/lib/interfaces.ts
+11
-1
11 additions, 1 deletion
ts/wasm/lib/interfaces.ts
with
28 additions
and
1 deletion
ts/wasm/lib/detailed/base_api.ts
+
17
−
0
View file @
ef862af4
...
...
@@ -107,6 +107,23 @@ export class WaxBaseApi implements IWaxBaseInterface {
return
this
.
proto
.
cpp_hbd_to_hive
(
hbdAsset
,
baseAsset
,
quoteAsset
)
as
NaiAsset
;
}
public
hiveToHbd
(
amount
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
,
base
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
,
quote
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
):
NaiAsset
{
const
amountAsset
=
isNaiAsset
(
amount
)
?
amount
as
NaiAsset
:
this
.
hive
(
amount
as
number
|
string
|
BigInt
|
Long
);
const
baseAsset
=
isNaiAsset
(
base
)
?
base
as
NaiAsset
:
this
.
hbd
(
base
as
number
|
string
|
BigInt
|
Long
);
const
quoteAsset
=
isNaiAsset
(
quote
)
?
quote
as
NaiAsset
:
this
.
hive
(
quote
as
number
|
string
|
BigInt
|
Long
);
if
(
amountAsset
.
nai
!==
this
.
ASSETS
.
HIVE
.
nai
)
throw
new
WaxError
(
'
Invalid asset type for HBD
'
);
if
(
baseAsset
.
nai
!==
this
.
ASSETS
.
HBD
.
nai
)
throw
new
WaxError
(
'
Invalid asset type for base
'
);
if
(
quoteAsset
.
nai
!==
this
.
ASSETS
.
HIVE
.
nai
)
throw
new
WaxError
(
'
Invalid asset type for quote
'
);
return
this
.
proto
.
cpp_hive_to_hbd
(
amountAsset
,
baseAsset
,
quoteAsset
)
as
NaiAsset
;
}
public
extract
(
res
:
result
):
string
{
if
(
res
.
value
!==
this
.
wax
.
error_code
.
ok
)
throw
new
WaxError
(
`Wax API error: "
${
String
(
res
.
exception_message
as
string
)}
"`
);
...
...
This diff is collapsed.
Click to expand it.
ts/wasm/lib/interfaces.ts
+
11
−
1
View file @
ef862af4
...
...
@@ -518,8 +518,18 @@ export interface IWaxBaseInterface {
* @param {NaiAsset} hbd HBD asset
* @param {NaiAsset} base HBD asset price base
* @param {NaiAsset} quote HIVE asset price quote
* @returns {NaiAsset} HIVE in nai form
*/
hbdToHive
(
hbd
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
,
base
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
,
quote
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
):
NaiAsset
;
/**
* Converts given amount of HIVE asset to HBD (nai form)
* @param {NaiAsset} amount HIVE asset
* @param {NaiAsset} base HBD asset price base taken i.e. from database_api.get_current_price_feed call
* @param {NaiAsset} quote HIVE asset price quote taken i.e. from database_api.get_current_price_feed call
* @returns {NaiAsset} HBD in nai form
*/
h
bdToHive
(
hbd
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
,
base
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
,
quote
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
):
NaiAsset
h
iveToHbd
(
amount
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
,
base
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
,
quote
:
number
|
string
|
BigInt
|
Long
|
NaiAsset
):
NaiAsset
;
/**
* Retrieves the public key in wif format from the given sig digest and signature in hexadecimal format
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment