Skip to content

Commit

Permalink
Fix eth bridge incoming history (#1614)
Browse files Browse the repository at this point in the history
* fix incoming history restoration

* up version to 1.44.3

* fix Jenkinsfile
  • Loading branch information
Nikita-Polyakov authored Feb 20, 2025
1 parent 0d82c83 commit 0006377
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def pipeline = new org.js.AppPipeline(steps: this,
vaultUser: "polkaswap-rw",
vaultCredId: "pswapVaultCreds",
valuesDestPath: "argocd-cc/src/charts/sora2/polkaswap-exchange-web/",
devValuesPath: "dev/dev/dev/",
devValuesPath: "test/dev/test/",
initialSecretName: "sora2-dev-polkaswap-exchange-polkaswap-exchange-web-eso-base",
initialNameSpace: "sora2-dev-web",
targetNameSpace: "sora2-${env.CHANGE_ID}-web",
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkaswap-exchange-web",
"version": "1.44.2",
"version": "1.44.3",
"repository": {
"type": "git",
"url": "https://github.com/sora-xor/polkaswap-exchange-web.git"
Expand Down Expand Up @@ -104,5 +104,6 @@
"eslint --fix",
"git add"
]
}
},
"packageManager": "[email protected]"
}
24 changes: 21 additions & 3 deletions src/utils/bridge/eth/classes/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,24 @@ export class EthBridgeHistory {
return tx;
}

public async fetchHistoryElements(address: string, timestamp = 0, ids?: string[]): Promise<HistoryElement[]> {
public async fetchHistoryElements({
address,
timestamp = 0,
ids,
isOutgoing = true,
}: {
address: string;
timestamp?: number;
ids?: string[];
isOutgoing?: boolean;
}): Promise<HistoryElement[]> {
const indexer = getCurrentIndexer();
const operations = [Operation.EthBridgeOutgoing, Operation.EthBridgeIncoming];
const filter = indexer.historyElementsFilter({ address, operations, timestamp, ids });
const filterCommonOptions = { operations, timestamp, ids };
const filterOptions = isOutgoing
? { address, ...filterCommonOptions }
: { ...filterCommonOptions, query: { accountAddress: address } };
const filter = indexer.historyElementsFilter(filterOptions);
const history: HistoryElement[] = [];

let hasNext = true;
Expand Down Expand Up @@ -307,7 +321,11 @@ export class EthBridgeHistory {
assetDataByAddress: (address?: Nullable<string>) => Nullable<RegisteredAccountAsset>,
updateCallback?: FnWithoutArgs | AsyncFnWithoutArgs
): Promise<void> {
const historyElements = await this.fetchHistoryElements(address, this.historySyncTimestamp);
const filter = { address, timestamp: this.historySyncTimestamp };
const outgoing = await this.fetchHistoryElements({ ...filter, isOutgoing: true });
const incoming = await this.fetchHistoryElements({ ...filter, isOutgoing: false });

const historyElements = [...outgoing, ...incoming];

if (!historyElements.length) return;

Expand Down
8 changes: 7 additions & 1 deletion src/utils/bridge/eth/classes/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ export class EthBridgeOutgoingReducer extends EthBridgeReducer {
// format account address to sora format
const { from: address } = getTransaction(id);
const bridgeHistory = await this.getBridgeHistoryInstance();
const historyItem = first(await bridgeHistory.fetchHistoryElements(address as string, 0, [tx.txId]));
const historyItem = first(
await bridgeHistory.fetchHistoryElements({
address: address as string,
ids: [tx.txId],
isOutgoing: true,
})
);

if (historyItem) {
this.updateTransactionParams(id, {
Expand Down

0 comments on commit 0006377

Please sign in to comment.