Skip to content

Commit 30df6ec

Browse files
feat: fetch txData from sdk
1 parent 07879b7 commit 30df6ec

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

packages/common/src/allo/backends/allo-v2.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
DonationVotingMerkleDistributionDirectTransferStrategyAbi,
88
DonationVotingMerkleDistributionStrategy,
99
DonationVotingMerkleDistributionStrategyTypes,
10+
DirectAllocationStrategy,
1011
Registry,
1112
RegistryAbi,
1213
StrategyFactory,
@@ -23,7 +24,7 @@ import {
2324
} from "data-layer";
2425
import { Abi, Address, Hex, getAddress, zeroAddress } from "viem";
2526
import { AnyJson } from "../..";
26-
import { UpdateRoundParams, MatchingStatsData } from "../../types";
27+
import { UpdateRoundParams, MatchingStatsData, Allocation } from "../../types";
2728
import { Allo, AlloError, AlloOperation, CreateRoundArguments } from "../allo";
2829
import {
2930
Result,
@@ -1483,16 +1484,25 @@ export class AlloV2 implements Allo {
14831484
}
14841485
}
14851486

1486-
const encodeData = utils.defaultAbiCoder.encode(
1487-
["address", "uint256", "address", "uint256"],
1488-
[args.recipient, args.amount, args.tokenAddress, args.nonce]
1489-
);
1487+
const strategy = new DirectAllocationStrategy({
1488+
chain: this.chainId,
1489+
poolId: BigInt(args.poolId),
1490+
});
1491+
1492+
const allocation: Allocation = {
1493+
profileOwner: args.recipient,
1494+
amount: BigInt(args.amount.toString()),
1495+
token: args.tokenAddress,
1496+
nonce: BigInt(args.nonce.toString()),
1497+
};
1498+
1499+
const txData = strategy.getAllocateData(allocation);
14901500

14911501
const tx = await sendTransaction(this.transactionSender, {
14921502
address: this.allo.address(),
14931503
abi: AlloAbi,
14941504
functionName: "allocate",
1495-
args: [poolId, encodeData as Hex],
1505+
args: [poolId, txData as Hex],
14961506
value: args.tokenAddress === zeroAddress ? args.amount : 0n,
14971507
});
14981508

packages/common/src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,10 @@ export type InputType =
9494
export type DeepRequired<T> = {
9595
[K in keyof T]: Required<DeepRequired<T[K]>>;
9696
};
97+
98+
export type Allocation = {
99+
profileOwner: `0x${string}`;
100+
amount: bigint;
101+
token: `0x${string}`;
102+
nonce: bigint;
103+
};

0 commit comments

Comments
 (0)