@boostxyz/sdk 5.3.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +2 -3
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +1696 -348
- package/dist/Actions/EventAction.js.map +1 -1
- package/package.json +1 -1
- package/src/Actions/EventAction.test.ts +9 -0
- package/src/Actions/EventAction.ts +37 -52
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
writeEventActionExecute,
|
|
7
7
|
} from '@boostxyz/evm';
|
|
8
8
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/EventAction.sol/EventAction.json';
|
|
9
|
+
import { abi } from '@boostxyz/signatures/events';
|
|
9
10
|
import { getTransaction, getTransactionReceipt } from '@wagmi/core';
|
|
10
|
-
import type { AbiEventParameter } from 'abitype';
|
|
11
11
|
import { match } from 'ts-pattern';
|
|
12
12
|
import {
|
|
13
13
|
type AbiEvent,
|
|
@@ -585,9 +585,15 @@ export class EventAction extends DeployableTarget<
|
|
|
585
585
|
) {
|
|
586
586
|
return undefined;
|
|
587
587
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
588
|
+
|
|
589
|
+
let decodedLogs: EventLogs;
|
|
590
|
+
if (signature === TRANSFER_SIGNATURE) {
|
|
591
|
+
({ decodedLogs } = await this.decodeTransferLogs(receipt));
|
|
592
|
+
} else {
|
|
593
|
+
decodedLogs = receipt.logs
|
|
594
|
+
.filter((log) => log.topics[0] === toEventSelector(event))
|
|
595
|
+
.map((log) => decodeAndReorderLogArgs(event, log));
|
|
596
|
+
}
|
|
591
597
|
|
|
592
598
|
for (let log of decodedLogs) {
|
|
593
599
|
if (!isAddressEqual(log.address, claimant.targetContract)) continue;
|
|
@@ -728,7 +734,8 @@ export class EventAction extends DeployableTarget<
|
|
|
728
734
|
|
|
729
735
|
// Special handling for Transfer events
|
|
730
736
|
if (actionStep.signature === TRANSFER_SIGNATURE) {
|
|
731
|
-
|
|
737
|
+
const { decodedLogs, event } = await this.decodeTransferLogs(receipt);
|
|
738
|
+
return this.isActionEventValid(actionStep, decodedLogs, event);
|
|
732
739
|
}
|
|
733
740
|
|
|
734
741
|
const decodedLogs = receipt.logs
|
|
@@ -801,7 +808,7 @@ export class EventAction extends DeployableTarget<
|
|
|
801
808
|
}
|
|
802
809
|
|
|
803
810
|
/**
|
|
804
|
-
* Decodes
|
|
811
|
+
* Decodes logs specifically for ERC721 and ERC20 Transfer events.
|
|
805
812
|
*
|
|
806
813
|
* This special handling is required because both ERC20 and ERC721 Transfer events:
|
|
807
814
|
* 1. Share the same event signature (0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef)
|
|
@@ -813,79 +820,51 @@ export class EventAction extends DeployableTarget<
|
|
|
813
820
|
* try decoding both ways to determine which type of Transfer event we're dealing with.
|
|
814
821
|
*
|
|
815
822
|
* @param {GetTransactionReceiptReturnType} receipt - The transaction receipt containing the logs
|
|
816
|
-
* @
|
|
817
|
-
* @returns {Promise<boolean>} - Returns true if the transfer logs are valid for either ERC20 or ERC721
|
|
823
|
+
* @returns {Promise<{ decodedLogs: EventLogs; event: AbiEvent }>} - Returns the decoded logs and the transfer event ABI used for decoding
|
|
818
824
|
* @throws {DecodedArgsError} - Throws if neither ERC20 nor ERC721 decoding succeeds
|
|
819
825
|
*/
|
|
820
826
|
private async decodeTransferLogs(
|
|
821
827
|
receipt: GetTransactionReceiptReturnType,
|
|
822
|
-
|
|
823
|
-
) {
|
|
828
|
+
): Promise<{ decodedLogs: EventLogs; event: AbiEvent }> {
|
|
824
829
|
const filteredLogs = receipt.logs.filter(
|
|
825
830
|
(log) => log.topics[0] === TRANSFER_SIGNATURE,
|
|
826
831
|
);
|
|
832
|
+
const event = abi[
|
|
833
|
+
'Transfer(address indexed,address indexed,uint256 indexed)'
|
|
834
|
+
] as AbiEvent;
|
|
827
835
|
|
|
828
836
|
// ERC721
|
|
829
837
|
try {
|
|
830
838
|
const decodedLogs = filteredLogs.map((log) => {
|
|
831
839
|
const { eventName, args } = decodeEventLog({
|
|
832
|
-
abi: [
|
|
833
|
-
{
|
|
834
|
-
name: 'Transfer',
|
|
835
|
-
type: 'event',
|
|
836
|
-
inputs: [
|
|
837
|
-
{ type: 'address', indexed: true },
|
|
838
|
-
{ type: 'address', indexed: true },
|
|
839
|
-
{ type: 'uint256', indexed: true },
|
|
840
|
-
],
|
|
841
|
-
},
|
|
842
|
-
],
|
|
840
|
+
abi: [event],
|
|
843
841
|
data: log.data,
|
|
844
842
|
topics: log.topics,
|
|
845
843
|
});
|
|
846
844
|
return { ...log, eventName, args };
|
|
847
845
|
});
|
|
848
846
|
|
|
849
|
-
return
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
{ type: 'address', indexed: true },
|
|
854
|
-
{ type: 'address', indexed: true },
|
|
855
|
-
{ type: 'uint256', indexed: true },
|
|
856
|
-
],
|
|
857
|
-
});
|
|
847
|
+
return {
|
|
848
|
+
decodedLogs,
|
|
849
|
+
event,
|
|
850
|
+
};
|
|
858
851
|
} catch {
|
|
859
852
|
// ERC20
|
|
860
853
|
try {
|
|
854
|
+
event.inputs[2]!.indexed = false;
|
|
861
855
|
const decodedLogs = filteredLogs.map((log) => {
|
|
862
856
|
const { eventName, args } = decodeEventLog({
|
|
863
|
-
abi: [
|
|
864
|
-
{
|
|
865
|
-
name: 'Transfer',
|
|
866
|
-
type: 'event',
|
|
867
|
-
inputs: [
|
|
868
|
-
{ type: 'address', indexed: true },
|
|
869
|
-
{ type: 'address', indexed: true },
|
|
870
|
-
{ type: 'uint256' },
|
|
871
|
-
],
|
|
872
|
-
},
|
|
873
|
-
],
|
|
857
|
+
abi: [event],
|
|
874
858
|
data: log.data,
|
|
875
859
|
topics: log.topics,
|
|
876
860
|
});
|
|
877
861
|
return { ...log, eventName, args };
|
|
878
862
|
});
|
|
879
863
|
|
|
880
|
-
return
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
{ type: 'address', indexed: true },
|
|
885
|
-
{ type: 'address', indexed: true },
|
|
886
|
-
{ type: 'uint256' },
|
|
887
|
-
],
|
|
888
|
-
});
|
|
864
|
+
return {
|
|
865
|
+
decodedLogs,
|
|
866
|
+
event,
|
|
867
|
+
};
|
|
889
868
|
} catch {
|
|
890
869
|
throw new DecodedArgsError('Failed to decode transfer logs');
|
|
891
870
|
}
|
|
@@ -1632,6 +1611,9 @@ export function packFieldIndexes(indexes: number[]): number {
|
|
|
1632
1611
|
}
|
|
1633
1612
|
packed |= (index & MAX_FIELD_INDEX) << (i * 6); // Each index occupies 6 bits
|
|
1634
1613
|
});
|
|
1614
|
+
if (indexes.length < 5) {
|
|
1615
|
+
packed |= MAX_FIELD_INDEX << (indexes.length * 6); // Terminator
|
|
1616
|
+
}
|
|
1635
1617
|
|
|
1636
1618
|
return packed;
|
|
1637
1619
|
}
|
|
@@ -1672,7 +1654,10 @@ export function decodeAndReorderLogArgs(event: AbiEvent, log: Log) {
|
|
|
1672
1654
|
: Object.values(decodedLog.args);
|
|
1673
1655
|
|
|
1674
1656
|
if (!event.inputs.some((input) => input.indexed)) {
|
|
1675
|
-
return
|
|
1657
|
+
return {
|
|
1658
|
+
...log,
|
|
1659
|
+
...decodedLog,
|
|
1660
|
+
} as EventLog;
|
|
1676
1661
|
}
|
|
1677
1662
|
|
|
1678
1663
|
const indexedIndices: number[] = [];
|
|
@@ -1685,7 +1670,7 @@ export function decodeAndReorderLogArgs(event: AbiEvent, log: Log) {
|
|
|
1685
1670
|
}
|
|
1686
1671
|
}
|
|
1687
1672
|
|
|
1688
|
-
const reorderedArgs =
|
|
1673
|
+
const reorderedArgs = Array.from({ length: event.inputs.length });
|
|
1689
1674
|
let currentIndex = 0;
|
|
1690
1675
|
|
|
1691
1676
|
// Place the indexed arguments in their original positions
|