Skip to content
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

chore: Fix mock ASE seeding script #3050

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
meta {
name: Get Asset By Code And Scale
type: graphql
seq: 52
}

post {
url: {{RafikiGraphqlHost}}/graphql
body: graphql
auth: none
}

body:graphql {
query GetAssetByCodeAndScale($code: String!, $scale: UInt8!) {
assetByCodeAndScale(code: $code, scale: $scale) {
code
createdAt
id
scale
withdrawalThreshold
liquidityThreshold
sendingFee {
id
type
basisPoints
fixed
}
receivingFee {
id
type
basisPoints
fixed
}
}
}

}

body:graphql:vars {
{
"code": "USD",
"scale": 2
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
meta {
name: Get Peer By Address and Asset Id
type: graphql
seq: 51
}

post {
url: {{RafikiGraphqlHost}}/graphql
body: graphql
auth: none
}

body:graphql {
query GetPeerByAddressAndAsset($address: String!, $assetId: String!) {
peerByAddressAndAsset(staticIlpAddress: $address, assetId: $assetId) {
id
name
http {
outgoing {
authToken
endpoint
}
}
liquidity
liquidityThreshold
}
}

}

body:graphql:vars {
{
"address": "test.happy-life-bank",
"assetId": "b7acf591-f77f-404b-bb31-d9ac96aba1f9"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
meta {
name: Get Wallet Address By Url
type: graphql
seq: 53
}

post {
url: {{RafikiGraphqlHost}}/graphql
body: graphql
auth: none
}

body:graphql {
query GetWalletAddress($url: String!) {
walletAddressByUrl(url: $url) {
id
asset {
id
code
scale
withdrawalThreshold
createdAt
}
createdAt
incomingPayments {
edges {
node {
id
state
incomingAmount {
value
}
receivedAmount {
value
}
}
cursor
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
walletAddressKeys {
edges {
node {
id
jwk {
kid
x
alg
kty
crv
}
revoked
createdAt
}
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
status
additionalProperties {
key
value
visibleInOpenPayments
}
}
}
}

body:graphql:vars {
{
"url": "https://cloud-nine-wallet-backend/accounts/broke"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
2 changes: 2 additions & 0 deletions bruno/collections/Rafiki/environments/Local Playground.bru
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ vars {
authApiSignatureVersion: 1
authApiSignatureSecret: rPoZpe9tVyBNCigm05QDco7WLcYa0xMao7lO5KG1XG4=
assetIdTigerBeetle: 1
assetCode: USD
assetScale: 2
}
26 changes: 26 additions & 0 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions packages/backend/src/asset/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface AssetService {
update(options: UpdateOptions): Promise<Asset | AssetError>
delete(options: DeleteOptions): Promise<Asset | AssetError>
get(id: string): Promise<void | Asset>
getByCodeAndScale(code: string, scale: number): Promise<void | Asset>
getPage(pagination?: Pagination, sortOrder?: SortOrder): Promise<Asset[]>
getAll(): Promise<Asset[]>
}
Expand All @@ -59,6 +60,8 @@ export async function createAssetService({
update: (options) => updateAsset(deps, options),
delete: (options) => deleteAsset(deps, options),
get: (id) => getAsset(deps, id),
getByCodeAndScale: (code, scale) =>
getAssetByCodeAndScale(deps, code, scale),
getPage: (pagination?, sortOrder?) =>
getAssetsPage(deps, pagination, sortOrder),
getAll: () => getAll(deps)
Expand Down Expand Up @@ -171,6 +174,16 @@ async function getAsset(
return await Asset.query(deps.knex).whereNull('deletedAt').findById(id)
}

async function getAssetByCodeAndScale(
deps: ServiceDependencies,
code: string,
scale: number
): Promise<void | Asset> {
return await Asset.query(deps.knex)
.where({ code: code, scale: scale })
.first()
}

async function getAssetsPage(
deps: ServiceDependencies,
pagination?: Pagination,
Expand Down
Loading
Loading