-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(api): parameterized transfer & transfer approval insert queries
- Loading branch information
Showing
5 changed files
with
197 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
with accountAddress := <UAddress>$account, | ||
localAccount := as_address(accountAddress), | ||
account := (select Account filter .address = accountAddress), | ||
resultId := <optional uuid>$result, | ||
result := assert_single((select Result filter .id = resultId and .transaction.account = account) if exists resultId else {}), | ||
from := <Address>$from, | ||
to := <Address>$to, | ||
transfer := ( | ||
insert TransferApproval { | ||
account := account, | ||
systxHash := <optional Bytes32>$systxHash, | ||
result := result, | ||
block := <bigint>$block, | ||
logIndex := <uint32>$logIndex, | ||
timestamp := <datetime>$timestamp, | ||
confirmed := (result is Confirmed ?? true), | ||
from := from, | ||
to := to, | ||
tokenAddress := <UAddress>$token, | ||
amount := <decimal>$amount, | ||
incoming := (to = localAccount), | ||
outgoing := (from = localAccount), | ||
isFeeTransfer := ((result.transaction.paymaster in {from, to}) ?? false) | ||
} unless conflict | ||
) | ||
select transfer; |
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,51 @@ | ||
// GENERATED by @edgedb/generate v0.5.4 | ||
|
||
import type {Executor} from "edgedb"; | ||
|
||
export type InsertTransferApprovalArgs = { | ||
readonly "account": string; | ||
readonly "result"?: string | null; | ||
readonly "from": string; | ||
readonly "to": string; | ||
readonly "systxHash"?: string | null; | ||
readonly "block": bigint; | ||
readonly "logIndex": number; | ||
readonly "timestamp": Date; | ||
readonly "token": string; | ||
readonly "amount": string; | ||
}; | ||
|
||
export type InsertTransferApprovalReturns = { | ||
"id": string; | ||
} | null; | ||
|
||
export function insertTransferApproval(client: Executor, args: InsertTransferApprovalArgs): Promise<InsertTransferApprovalReturns> { | ||
return client.querySingle(`\ | ||
with accountAddress := <UAddress>$account, | ||
localAccount := as_address(accountAddress), | ||
account := (select Account filter .address = accountAddress), | ||
resultId := <optional uuid>$result, | ||
result := assert_single((select Result filter .id = resultId and .transaction.account = account) if exists resultId else {}), | ||
from := <Address>$from, | ||
to := <Address>$to, | ||
transfer := ( | ||
insert TransferApproval { | ||
account := account, | ||
systxHash := <optional Bytes32>$systxHash, | ||
result := result, | ||
block := <bigint>$block, | ||
logIndex := <uint32>$logIndex, | ||
timestamp := <datetime>$timestamp, | ||
confirmed := (result is Confirmed ?? true), | ||
from := from, | ||
to := to, | ||
tokenAddress := <UAddress>$token, | ||
amount := <decimal>$amount, | ||
incoming := (to = localAccount), | ||
outgoing := (from = localAccount), | ||
isFeeTransfer := ((result.transaction.paymaster in {from, to}) ?? false) | ||
} unless conflict | ||
) | ||
select transfer;`, args); | ||
|
||
} |
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,31 @@ | ||
with accountAddress := <UAddress>$account, | ||
localAccount := as_address(accountAddress), | ||
account := (select Account filter .address = accountAddress), | ||
resultId := <optional uuid>$result, | ||
result := assert_single((select Result filter .id = resultId and .transaction.account = account) if exists resultId else {}), | ||
from := <Address>$from, | ||
to := <Address>$to, | ||
transfer := ( | ||
insert Transfer { | ||
account := account, | ||
systxHash := <optional Bytes32>$systxHash, | ||
result := result, | ||
block := <bigint>$block, | ||
logIndex := <uint32>$logIndex, | ||
timestamp := <datetime>$timestamp, | ||
confirmed := (result is Confirmed ?? true), | ||
from := from, | ||
to := to, | ||
tokenAddress := <UAddress>$token, | ||
amount := <decimal>$amount, | ||
incoming := (to = localAccount), | ||
outgoing := (from = localAccount), | ||
isFeeTransfer := ((result.transaction.paymaster in {from, to}) ?? false) | ||
} unless conflict | ||
) | ||
select transfer { | ||
id, | ||
internal, | ||
isFeeTransfer, | ||
accountUsers := .account.approvers.user.id | ||
} |
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,59 @@ | ||
// GENERATED by @edgedb/generate v0.5.4 | ||
|
||
import type {Executor} from "edgedb"; | ||
|
||
export type InsertTransferArgs = { | ||
readonly "account": string; | ||
readonly "result"?: string | null; | ||
readonly "from": string; | ||
readonly "to": string; | ||
readonly "systxHash"?: string | null; | ||
readonly "block": bigint; | ||
readonly "logIndex": number; | ||
readonly "timestamp": Date; | ||
readonly "token": string; | ||
readonly "amount": string; | ||
}; | ||
|
||
export type InsertTransferReturns = { | ||
"id": string; | ||
"internal": boolean; | ||
"isFeeTransfer": boolean; | ||
"accountUsers": Array<string>; | ||
} | null; | ||
|
||
export function insertTransfer(client: Executor, args: InsertTransferArgs): Promise<InsertTransferReturns> { | ||
return client.querySingle(`\ | ||
with accountAddress := <UAddress>$account, | ||
localAccount := as_address(accountAddress), | ||
account := (select Account filter .address = accountAddress), | ||
resultId := <optional uuid>$result, | ||
result := assert_single((select Result filter .id = resultId and .transaction.account = account) if exists resultId else {}), | ||
from := <Address>$from, | ||
to := <Address>$to, | ||
transfer := ( | ||
insert Transfer { | ||
account := account, | ||
systxHash := <optional Bytes32>$systxHash, | ||
result := result, | ||
block := <bigint>$block, | ||
logIndex := <uint32>$logIndex, | ||
timestamp := <datetime>$timestamp, | ||
confirmed := (result is Confirmed ?? true), | ||
from := from, | ||
to := to, | ||
tokenAddress := <UAddress>$token, | ||
amount := <decimal>$amount, | ||
incoming := (to = localAccount), | ||
outgoing := (from = localAccount), | ||
isFeeTransfer := ((result.transaction.paymaster in {from, to}) ?? false) | ||
} unless conflict | ||
) | ||
select transfer { | ||
id, | ||
internal, | ||
isFeeTransfer, | ||
accountUsers := .account.approvers.user.id | ||
}`, args); | ||
|
||
} |
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