Skip to content

Commit

Permalink
feat: rename add liquidity mutations to deposit (#2304)
Browse files Browse the repository at this point in the history
* feat(liquidity): rename addAssetLiquidity to depositAssetLiquidity

BREAKING CHANGE: Renamed addAssetLiquidity resolver to depositAssetLiquidity for clarity and consistency.

* feat(liquidity): rename addPeertLiquidity to depositPeerLiquidity

BREAKING CHANGE: Renamed addPeerLiquidity resolver to depositPeerLiquidity for clarity and consistency.

* chore(backend): update test name verbiage from add to deposit

* chore(backend): update error verbiage from add to deposit

* chore(backend): update gql schema comment verbiage from add to deposit

* fix(frontend): upadte to use new resolver names

* fix(localenv): update mock ase to use new mutation names

* fix(localenv,documentation): update docs

* refactor: rename add liquidity service methods to deposit

* feat: rename addedLiquidity to depositedLiquidity

BREAKING CHANGE: Renamed addedLiquidity field to depositedLiquidity on graphql  CreateOrUpdatePeerByUrlInput for consistency.

* fix(postman): update request to use new deposit name

* fix(frontend): change "add" to "deposit" liquidity

* refactor(backend): update verbiage from add to deposit liquidity

* refactor: change depositedLiquidity to liquidityToDeposit

* Update packages/documentation/src/content/docs/concepts/interledger-protocol/peering.md

Co-authored-by: Max Kurapov <[email protected]>

* fix(documentation): bad json

---------

Co-authored-by: Max Kurapov <[email protected]>
  • Loading branch information
BlairCurrey and mkurapov authored Jan 9, 2024
1 parent 852972d commit 41e31ef
Show file tree
Hide file tree
Showing 26 changed files with 566 additions and 542 deletions.
20 changes: 10 additions & 10 deletions localenv/docs/peer-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ Example Successful Response
}
```

Next, run the following query to add liquidity for the secondary instance
Next, run the following query to deposit liquidity for the secondary instance

Query:

```
mutation AddPeerLiquidity ($input: AddPeerLiquidityInput!) {
addPeerLiquidity(input: $input) {
mutation DepositPeerLiquidity ($input: DepositPeerLiquidityInput!) {
depositPeerLiquidity(input: $input) {
code
success
message
Expand All @@ -172,10 +172,10 @@ Example successful response:
```
{
"data": {
"addPeerLiquidity": {
"depositPeerLiquidity": {
"code": "200",
"success": true,
"message": "Added peer liquidity",
"message": "Deposited peer liquidity",
"error": null
}
}
Expand Down Expand Up @@ -296,13 +296,13 @@ Example successful response:
}
```

Next, run the following query to add liquidity for the primary instance
Next, run the following query to deposit liquidity for the primary instance

Query:

```
mutation AddPeerLiquidity ($input: AddPeerLiquidityInput!) {
addPeerLiquidity(input: $input) {
mutation DepositPeerLiquidity ($input: DepositPeerLiquidityInput!) {
depositPeerLiquidity(input: $input) {
code
success
message
Expand All @@ -328,10 +328,10 @@ Example successful response:
```
{
"data": {
"addPeerLiquidity": {
"depositPeerLiquidity": {
"code": "200",
"success": true,
"message": "Added peer liquidity",
"message": "Deposited peer liquidity",
"error": null
}
}
Expand Down
40 changes: 20 additions & 20 deletions localenv/mock-account-servicing-entity/app/lib/requesters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ export async function createAutoPeer(
}
`

const addedLiquidity = '10000' as unknown as bigint
const liquidityToDeposit = '10000' as unknown as bigint
const createPeerInput: { input: CreateOrUpdatePeerByUrlInput } = {
input: {
peerUrl,
assetId,
addedLiquidity
liquidityToDeposit
}
}
return apolloClient
Expand All @@ -164,22 +164,22 @@ export async function createAutoPeer(
})
}

export async function addPeerLiquidity(
export async function depositPeerLiquidity(
peerId: string,
amount: string,
transferUid: string
): Promise<LiquidityMutationResponse> {
const addPeerLiquidityMutation = gql`
mutation AddPeerLiquidity($input: AddPeerLiquidityInput!) {
addPeerLiquidity(input: $input) {
const depositPeerLiquidityMutation = gql`
mutation DepositPeerLiquidity($input: DepositPeerLiquidityInput!) {
depositPeerLiquidity(input: $input) {
code
success
message
error
}
}
`
const addPeerLiquidityInput = {
const depositPeerLiquidityInput = {
input: {
peerId: peerId,
amount: amount,
Expand All @@ -189,34 +189,34 @@ export async function addPeerLiquidity(
}
return apolloClient
.mutate({
mutation: addPeerLiquidityMutation,
variables: addPeerLiquidityInput
mutation: depositPeerLiquidityMutation,
variables: depositPeerLiquidityInput
})
.then(({ data }): LiquidityMutationResponse => {
console.log(data)
if (!data.addPeerLiquidity.success) {
if (!data.depositPeerLiquidity.success) {
throw new Error('Data was empty')
}
return data.addPeerLiquidity
return data.depositPeerLiquidity
})
}

export async function addAssetLiquidity(
export async function depositAssetLiquidity(
assetId: string,
amount: number,
transferId: string
): Promise<LiquidityMutationResponse> {
const addAssetLiquidityMutation = gql`
mutation AddAssetLiquidity($input: AddAssetLiquidityInput!) {
addAssetLiquidity(input: $input) {
const depositAssetLiquidityMutation = gql`
mutation DepositAssetLiquidity($input: DepositAssetLiquidityInput!) {
depositAssetLiquidity(input: $input) {
code
success
message
error
}
}
`
const addAssetLiquidityInput = {
const depositAssetLiquidityInput = {
input: {
assetId,
amount,
Expand All @@ -226,15 +226,15 @@ export async function addAssetLiquidity(
}
return apolloClient
.mutate({
mutation: addAssetLiquidityMutation,
variables: addAssetLiquidityInput
mutation: depositAssetLiquidityMutation,
variables: depositAssetLiquidityInput
})
.then(({ data }): LiquidityMutationResponse => {
console.log(data)
if (!data.addAssetLiquidity.success) {
if (!data.depositAssetLiquidity.success) {
throw new Error('Data was empty')
}
return data.addAssetLiquidity
return data.depositAssetLiquidity
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
import {
createAsset,
createPeer,
addPeerLiquidity,
depositPeerLiquidity,
createWalletAddress,
createWalletAddressKey,
setFee,
addAssetLiquidity,
depositAssetLiquidity,
createAutoPeer
} from './requesters'
import { v4 } from 'uuid'
Expand All @@ -28,10 +28,14 @@ export async function setupFromSeed(config: Config): Promise<void> {
throw new Error('asset not defined')
}

const addedLiquidity = await addAssetLiquidity(asset.id, liquidity, v4())
const initialLiquidity = await depositAssetLiquidity(
asset.id,
liquidity,
v4()
)

assets[code] = asset
console.log(JSON.stringify({ asset, addedLiquidity }, null, 2))
console.log(JSON.stringify({ asset, initialLiquidity }, null, 2))

const { fees } = config.seed
const fee = fees.find((fee) => fee.asset === code && fee.scale == scale)
Expand All @@ -55,7 +59,7 @@ export async function setupFromSeed(config: Config): Promise<void> {
throw new Error('peer response not defined')
}
const transferUid = v4()
const liquidity = await addPeerLiquidity(
const liquidity = await depositPeerLiquidity(
peerResponse.id,
peer.initialLiquidity,
transferUid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { mockAccounts } from './accounts.server'
import { apolloClient } from './apolloClient'
import { v4 as uuid } from 'uuid'
import {
addAssetLiquidity,
addPeerLiquidity,
depositAssetLiquidity,
depositPeerLiquidity,
createWalletAddress
} from './requesters'

Expand Down Expand Up @@ -210,8 +210,8 @@ export async function handleLowLiquidity(wh: WebHook) {
}

if (wh.type == 'asset.liquidity_low') {
await addAssetLiquidity(id, 1000000, uuid())
await depositAssetLiquidity(id, 1000000, uuid())
} else {
await addPeerLiquidity(id, '1000000', uuid())
await depositPeerLiquidity(id, '1000000', uuid())
}
}
Loading

0 comments on commit 41e31ef

Please sign in to comment.