@boostxyz/sdk 1.1.0-alpha.23 → 1.1.0-alpha.24
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 +27 -0
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +108 -82
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +121 -120
- package/package.json +3 -3
- package/src/Actions/EventAction.test.ts +381 -122
- package/src/Actions/EventAction.ts +60 -0
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
fromHex,
|
|
26
26
|
isAddress,
|
|
27
27
|
isAddressEqual,
|
|
28
|
+
zeroAddress,
|
|
28
29
|
zeroHash,
|
|
29
30
|
} from 'viem';
|
|
30
31
|
import { EventAction as EventActionBases } from '../../dist/deployments.json';
|
|
@@ -482,6 +483,8 @@ export class EventAction extends DeployableTarget<
|
|
|
482
483
|
/**
|
|
483
484
|
* Derives the action claimant address from a transaction based on the provided ActionClaimant configuration.
|
|
484
485
|
* This method supports both event-based and function-based claimant derivation.
|
|
486
|
+
* **Important**: The claimant is considered to be `transaction.from` when `claimant.fieldIndex` is 255.
|
|
487
|
+
* This may have unintended side effects for bridged transactions and SCW transactions, so these are considered unsupported use cases for the time being.
|
|
485
488
|
*
|
|
486
489
|
** @example
|
|
487
490
|
* // Example usage
|
|
@@ -515,7 +518,30 @@ export class EventAction extends DeployableTarget<
|
|
|
515
518
|
claimant: ActionClaimant,
|
|
516
519
|
params: ValidateActionStepParams,
|
|
517
520
|
): Promise<Address | undefined> {
|
|
521
|
+
// find message sender and return it
|
|
522
|
+
// WARNING: this is error prone in bridged transactions and SCW transactions, as this will return exit node
|
|
523
|
+
if (claimant.fieldIndex === 255) {
|
|
524
|
+
if ('hash' in params) {
|
|
525
|
+
const transaction = await getTransaction(this._config, {
|
|
526
|
+
hash: params.hash,
|
|
527
|
+
});
|
|
528
|
+
return transaction.from;
|
|
529
|
+
}
|
|
530
|
+
if ('logs' in params) {
|
|
531
|
+
for (let log of params.logs) {
|
|
532
|
+
if (log.transactionHash) {
|
|
533
|
+
const transaction = await getTransaction(this._config, {
|
|
534
|
+
hash: log.transactionHash,
|
|
535
|
+
});
|
|
536
|
+
return transaction.from;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return undefined;
|
|
541
|
+
}
|
|
542
|
+
|
|
518
543
|
const signature = claimant.signature;
|
|
544
|
+
|
|
519
545
|
if (claimant.signatureType === SignatureType.EVENT) {
|
|
520
546
|
let event: AbiEvent;
|
|
521
547
|
if (params.abiItem) event = params.abiItem as AbiEvent;
|
|
@@ -1242,3 +1268,37 @@ export function anyActionParameter(): Criteria {
|
|
|
1242
1268
|
filterData: zeroHash,
|
|
1243
1269
|
};
|
|
1244
1270
|
}
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* Creates an ActionClaimant object that represents the transaction sender as the claimant.
|
|
1274
|
+
* This function is useful when you want to set up an action where the transaction sender is always considered the valid claimant,
|
|
1275
|
+
* regardless of the event or function parameters.
|
|
1276
|
+
*
|
|
1277
|
+
* The returned ActionClaimant has the following properties:
|
|
1278
|
+
* - signatureType: Set to SignatureType.EVENT (though it doesn't matter for this case)
|
|
1279
|
+
* - signature: Set to zeroHash (0x0000...0000)
|
|
1280
|
+
* - fieldIndex: Set to 255, indicating "any" field
|
|
1281
|
+
* - targetContract: Set to zeroAddress (0x0000...0000)
|
|
1282
|
+
* - chainid: Set to 0, indicating it's valid for any chain
|
|
1283
|
+
*
|
|
1284
|
+
* @returns {ActionClaimant} An ActionClaimant object representing the msg.sender
|
|
1285
|
+
*
|
|
1286
|
+
* @example
|
|
1287
|
+
* const eventAction = new EventAction();
|
|
1288
|
+
* const payload: EventActionPayload = {
|
|
1289
|
+
* actionClaimant: transactionSenderClaimant(),
|
|
1290
|
+
* actionSteps: [
|
|
1291
|
+
* // ... define your action steps here
|
|
1292
|
+
* ]
|
|
1293
|
+
* };
|
|
1294
|
+
* await eventAction.deploy(payload);
|
|
1295
|
+
*/
|
|
1296
|
+
export function transactionSenderClaimant(): ActionClaimant {
|
|
1297
|
+
return {
|
|
1298
|
+
signatureType: SignatureType.EVENT,
|
|
1299
|
+
signature: zeroHash,
|
|
1300
|
+
fieldIndex: 255,
|
|
1301
|
+
targetContract: zeroAddress,
|
|
1302
|
+
chainid: 0,
|
|
1303
|
+
};
|
|
1304
|
+
}
|