Skip to content

Commit

Permalink
Merge pull request #320 from Once-Upon/feature/ou-2203-add-asset-flow…
Browse files Browse the repository at this point in the history
…-to-default-sentence-for-completed-cross-chain

add asset flow to default sentence for completed cross chain
  • Loading branch information
pcowgill authored Apr 17, 2024
2 parents cab5f73 + a25fc05 commit 2d22b5f
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/contextualizers/bridges/degen/destination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Degen Bridge Destination', () => {
);
expect(transaction.context?.summaries?.en.title).toBe('Bridge');
expect(contextSummary(transaction.context)).toBe(
'0x888f05d02ea7b42f32f103c089c1750170830642 COMPLETED_A_CROSS_CHAIN_INTERACTION via 0x729170d38dd5449604f35f349fdfcc9ad08257cd',
'0x888f05d02ea7b42f32f103c089c1750170830642 COMPLETED_A_CROSS_CHAIN_INTERACTION via 0x729170d38dd5449604f35f349fdfcc9ad08257cd and 470.99999367238779 ETH was transferred',
);
expect(containsBigInt(transaction.context)).toBe(false);
});
Expand Down
8 changes: 7 additions & 1 deletion src/contextualizers/bridges/degen/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export function generate(transaction: Transaction): Transaction {
category: 'MULTICHAIN',
en: {
title: `Bridge`,
default: '[[person]][[completedACrossChainInteraction]]via[[address]]',
default:
'[[person]][[completedACrossChainInteraction]]via[[address]]and[[asset]]was transferred',
},
},
variables: {
Expand All @@ -73,6 +74,11 @@ export function generate(transaction: Transaction): Transaction {
type: 'address',
value: transaction.to,
},
asset: {
type: AssetType.ETH,
value: assetTransfer.value,
unit: 'wei',
},
completedACrossChainInteraction: {
type: 'contextAction',
value: BridgeContextActionEnum.COMPLETED_A_CROSS_CHAIN_INTERACTION,
Expand Down
25 changes: 20 additions & 5 deletions src/contextualizers/bridges/reservoir/destination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Transaction } from '../../../types';
import { detect, generate } from './destination';
import { containsBigInt, contextSummary } from '../../../helpers/utils';
import bridgeZoraEnergyDestination0x7e7843df from '../../test/transactions/bridgeZoraEnergyDestination-0x7e7843df.json';
import bridgeZoraEnergyDestination0x1edd564e from '../../test/transactions/bridgeZoraEnergyDestination-0x1edd564e.json';
import hopDestination0x0902ccb6 from '../../test/transactions/hop-destination-0x0902ccb6.json';

describe('Bridge Zora Energy Destination', () => {
Expand All @@ -15,16 +16,30 @@ describe('Bridge Zora Energy Destination', () => {
hopDestination0x0902ccb6 as unknown as Transaction,
);
expect(isBridgeZoraEnergyDestination2).toBe(false);

const isBridgeZoraEnergyDestination3 = detect(
bridgeZoraEnergyDestination0x1edd564e as unknown as Transaction,
);
expect(isBridgeZoraEnergyDestination3).toBe(true);
});

it('Should generate context', () => {
const transaction = generate(
const transaction1 = generate(
bridgeZoraEnergyDestination0x7e7843df as unknown as Transaction,
);
expect(transaction.context?.summaries?.en.title).toBe('Bridge');
expect(contextSummary(transaction.context)).toBe(
'0x74b78e98093f5b522a7ebdac3b994641ca7c2b20 COMPLETED_A_CROSS_CHAIN_INTERACTION via 0xf70da97812cb96acdf810712aa562db8dfa3dbef',
expect(transaction1.context?.summaries?.en.title).toBe('Bridge');
expect(contextSummary(transaction1.context)).toBe(
'0x74b78e98093f5b522a7ebdac3b994641ca7c2b20 COMPLETED_A_CROSS_CHAIN_INTERACTION via 0xf70da97812cb96acdf810712aa562db8dfa3dbef and 0.02 ETH was transferred',
);
expect(containsBigInt(transaction1.context)).toBe(false);

const transaction2 = generate(
bridgeZoraEnergyDestination0x1edd564e as unknown as Transaction,
);
expect(transaction2.context?.summaries?.en.title).toBe('Bridge');
expect(contextSummary(transaction2.context)).toBe(
'0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f COMPLETED_A_CROSS_CHAIN_INTERACTION via 0xf70da97812cb96acdf810712aa562db8dfa3dbef and 0.26754098684670663 ETH was transferred',
);
expect(containsBigInt(transaction.context)).toBe(false);
expect(containsBigInt(transaction2.context)).toBe(false);
});
});
3 changes: 2 additions & 1 deletion src/contextualizers/bridges/reservoir/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export function generate(transaction: Transaction): Transaction {
category: 'MULTICHAIN',
en: {
title: `Bridge`,
default: '[[person]][[completedACrossChainInteraction]]via[[address]]',
default:
'[[person]][[completedACrossChainInteraction]]via[[address]]and[[asset]]was transferred',
},
},
variables: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"_id": "661d911b84b983a70babd907",
"accessList": [],
"blockHash": "0x5536967894e93a85ead212dab042b820dc5f4530acca8b8ae34ab4bf5907cf51",
"blockNumber": 13212184,
"chainId": 8453,
"from": "0xf70da97812cb96acdf810712aa562db8dfa3dbef",
"gas": 25200,
"gasPrice": "138005700",
"hash": "0x1edd2e93514801de58e440391b00ca6591855ea76fcfa300d52e31d9cb00564e",
"input": "0x562ffb",
"maxFeePerGas": "149824286",
"maxPriorityFeePerGas": "21099610",
"nonce": 337195,
"r": "0x7def2c8971ddb3f9563d920ff5a2960a33c1985ed860a6763f71d57bf8a0bc8c",
"s": "0x259b020e3f1ed4889c3aa4bc1f7f8dd3cd24aa1139f07085bf4f2764c042b9aa",
"to": "0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f",
"transactionIndex": 11,
"type": 2,
"v": "0x1",
"value": "267540986846706630",
"yParity": "0x1",
"receipt": {
"blockHash": "0x5536967894e93a85ead212dab042b820dc5f4530acca8b8ae34ab4bf5907cf51",
"blockNumber": 13212184,
"contractAddress": null,
"cumulativeGasUsed": 1350771,
"effectiveGasPrice": 138005700,
"from": "0xf70da97812cb96acdf810712aa562db8dfa3dbef",
"gasUsed": 21048,
"l1Fee": "0x737eecd0b",
"l1GasPrice": "0x34734e01c",
"l1GasUsed": "0x7d0",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": true,
"to": "0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f",
"transactionHash": "0x1edd2e93514801de58e440391b00ca6591855ea76fcfa300d52e31d9cb00564e",
"transactionIndex": 11,
"type": "0x2"
},
"decoded": null,
"assetTransfers": [
{
"from": "0xf70da97812cb96acdf810712aa562db8dfa3dbef",
"to": "0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f",
"type": "eth",
"value": "267540986846706630"
}
],
"delegateCalls": [],
"neighbor": {
"address": "0xf70da97812cb96acdf810712aa562db8dfa3dbef",
"neighbor": "0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f"
},
"errors": [],
"parties": [
"0xf70da97812cb96acdf810712aa562db8dfa3dbef",
"0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f"
],
"sigHash": "0x562ffb",
"internalSigHashes": [
{
"from": "0xf70da97812cb96acdf810712aa562db8dfa3dbef",
"to": "0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f",
"sigHash": "0x562ffb"
}
],
"timestamp": 1713213715,
"baseFeePerGas": 116906090,
"transactionFee": "2904743973600",
"logs": [],
"netAssetTransfers": {
"0xf70da97812cb96acdf810712aa562db8dfa3dbef": {
"received": [],
"sent": [
{
"type": "eth",
"value": "267540986846706630"
}
]
},
"0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f": {
"received": [
{
"type": "eth",
"value": "267540986846706630"
}
],
"sent": []
}
},
"contractsCreated": [],
"enrichedParties": {
"0xf70da97812cb96acdf810712aa562db8dfa3dbef": [
{
"chainId": 1,
"isContract": false,
"ensNew": {
"handle": null,
"avatar": null
},
"bns": {
"handle": null,
"avatar": null
},
"farcaster": {
"handle": null,
"avatar": null,
"fid": null
}
}
],
"0xc761b876e04afa1a67c76bfd8c2c7aa5a5e8e35f": [
{
"chainId": 1,
"isContract": false,
"ensNew": {
"handle": null,
"avatar": null
},
"bns": {
"handle": null,
"avatar": null
},
"farcaster": {
"handle": null,
"avatar": null,
"fid": null
}
}
]
},
"assetsEnriched": {}
}

0 comments on commit 2d22b5f

Please sign in to comment.