-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
70 deletions.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
packages/blockchain-providers/src/ergo-graphql/queries.spec.ts
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,16 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { ALL_BOX_QUERY, CONF_BOX_QUERY } from "./queries"; | ||
|
||
describe("Box queries", () => { | ||
it("Should build confirmed box query", () => { | ||
expect(CONF_BOX_QUERY).to.be.equal( | ||
`query boxes($spent: Boolean! $boxIds: [String!] $ergoTrees: [String!] $ergoTreeTemplateHash: String $tokenId: String $skip: Int $take: Int) { boxes(spent: $spent boxIds: $boxIds ergoTrees: $ergoTrees ergoTreeTemplateHash: $ergoTreeTemplateHash tokenId: $tokenId skip: $skip take: $take) { boxId transactionId index value creationHeight ergoTree assets { tokenId amount } additionalRegisters beingSpent } }` | ||
); | ||
}); | ||
|
||
it("Should build confirmed + unconfirmed box query", () => { | ||
expect(ALL_BOX_QUERY).to.be.equal( | ||
`query boxes($spent: Boolean! $boxIds: [String!] $ergoTrees: [String!] $ergoTreeTemplateHash: String $tokenId: String $skip: Int $take: Int) { boxes(spent: $spent boxIds: $boxIds ergoTrees: $ergoTrees ergoTreeTemplateHash: $ergoTreeTemplateHash tokenId: $tokenId skip: $skip take: $take) { boxId transactionId index value creationHeight ergoTree assets { tokenId amount } additionalRegisters beingSpent } mempool { boxes(boxIds: $boxIds ergoTrees: $ergoTrees ergoTreeTemplateHash: $ergoTreeTemplateHash tokenId: $tokenId skip: $skip take: $take) { boxId transactionId index value creationHeight ergoTree assets { tokenId amount } additionalRegisters beingSpent } } }` | ||
); | ||
}); | ||
}); |
79 changes: 11 additions & 68 deletions
79
packages/blockchain-providers/src/ergo-graphql/queries.ts
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 |
---|---|---|
@@ -1,68 +1,11 @@ | ||
import { gql } from "../utils"; | ||
|
||
export const CONF_BOX_QUERY = gql` | ||
query boxes( | ||
$spent: Boolean! | ||
$boxIds: [String!] | ||
$ergoTrees: [String!] | ||
$ergoTreeTemplateHash: String | ||
$tokenId: String | ||
$skip: Int | ||
$take: Int | ||
) { | ||
boxes( | ||
spent: $spent | ||
boxIds: $boxIds | ||
ergoTrees: $ergoTrees | ||
ergoTreeTemplateHash: $ergoTreeTemplateHash | ||
tokenId: $tokenId | ||
skip: $skip | ||
take: $take | ||
) { | ||
boxId | ||
transactionId | ||
index | ||
value | ||
creationHeight | ||
ergoTree | ||
assets { | ||
tokenId | ||
amount | ||
} | ||
additionalRegisters | ||
beingSpent | ||
} | ||
} | ||
`; | ||
|
||
export const HEADERS_QUERY = gql` | ||
query blockHeaders($take: Int) { | ||
blockHeaders(take: $take) { | ||
headerId | ||
timestamp | ||
version | ||
adProofsRoot | ||
stateRoot | ||
transactionsRoot | ||
nBits | ||
extensionHash | ||
powSolutions | ||
height | ||
difficulty | ||
parentId | ||
votes | ||
} | ||
} | ||
`; | ||
|
||
export const CHECK_TX_MUTATION = gql` | ||
mutation checkTransaction($signedTransaction: SignedTransaction!) { | ||
checkTransaction(signedTransaction: $signedTransaction) | ||
} | ||
`; | ||
|
||
export const SEND_TX_MUTATION = gql` | ||
mutation submitTransaction($signedTransaction: SignedTransaction!) { | ||
submitTransaction(signedTransaction: $signedTransaction) | ||
} | ||
`; | ||
const B = [ | ||
`query boxes($spent: Boolean! $boxIds: [String!] $ergoTrees: [String!] $ergoTreeTemplateHash: String $tokenId: String $skip: Int $take: Int)`, | ||
`boxIds: $boxIds ergoTrees: $ergoTrees ergoTreeTemplateHash: $ergoTreeTemplateHash tokenId: $tokenId skip: $skip take: $take`, | ||
`boxId transactionId index value creationHeight ergoTree assets { tokenId amount } additionalRegisters beingSpent` | ||
]; | ||
|
||
export const CONF_BOX_QUERY = `${B[0]} { boxes(spent: $spent ${B[1]}) { ${B[2]} } }`; | ||
export const ALL_BOX_QUERY = `${B[0]} { boxes(spent: $spent ${B[1]}) { ${B[2]} } mempool { boxes(${B[1]}) { ${B[2]} } } }`; | ||
export const HEADERS_QUERY = `query blockHeaders($take: Int) { blockHeaders(take: $take) {headerId timestamp version adProofsRoot stateRoot transactionsRoot nBits extensionHash powSolutions height difficulty parentId votes } }`; | ||
export const CHECK_TX_MUTATION = `mutation checkTransaction($signedTransaction: SignedTransaction!) { checkTransaction(signedTransaction: $signedTransaction) }`; | ||
export const SEND_TX_MUTATION = `mutation submitTransaction($signedTransaction: SignedTransaction!) { submitTransaction(signedTransaction: $signedTransaction) }`; |