Skip to content

Commit

Permalink
Merge pull request #69 from moreal/bugfix/garage-rdb
Browse files Browse the repository at this point in the history
Branch agent,avatar address
  • Loading branch information
moreal authored Dec 1, 2023
2 parents 357d674 + 22826f7 commit 0280624
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/sync/upstream/events/garage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account } from "@planetarium/account";
import { Account, Address } from "@planetarium/account";
import { signTx } from "@planetarium/tx";
import { ResponseType } from "@prisma/client";
import {
Expand All @@ -16,6 +16,10 @@ export async function responseTransactionsFromGarageEvents(
networkId: string,
genesisHash: Uint8Array,
startNonce: bigint,
vaultAddresses: {
agentAddress: Address;
avatarAddress: Address;
},
): Promise<BridgeResponse[]> {
const signerAddress = await account.getAddress();
const responses: BridgeResponse[] = [];
Expand All @@ -28,10 +32,17 @@ export async function responseTransactionsFromGarageEvents(
} of events) {
const requests: (IFungibleAssetValues | IFungibleItems)[] = [];
for (const fa of fungibleAssetValues) {
requests.push({
recipient: agentAddress,
amount: fa[1],
});
if (fa[0].equals(vaultAddresses.agentAddress)) {
requests.push({
recipient: agentAddress,
amount: fa[1],
});
} else if (fa[0].equals(vaultAddresses.avatarAddress)) {
requests.push({
recipient: avatarAddress,
amount: fa[1],
});
}
}

for (const fi of fungibleItems) {
Expand Down
4 changes: 4 additions & 0 deletions src/sync/upstream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export async function processUpstreamEvents(
downstreamNetworkId,
downstreamGenesisHash,
downstreamNextTxNonce,
{
agentAddress,
avatarAddress,
},
)),
...(await responseTransactionsFromTransferEvents(
transferAssetEvents,
Expand Down

0 comments on commit 0280624

Please sign in to comment.