Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 133 additions & 2 deletions src/abi/IWithdrawalCompressorV310.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IWithdrawalCompressorV310
// WithdrawalCompressorV310
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

export const iWithdrawalCompressorV310Abi = [
{
type: "constructor",
inputs: [
{ name: "_owner", internalType: "address", type: "address" },
{ name: "addressProvider_", internalType: "address", type: "address" },
],
stateMutability: "nonpayable",
},
{
type: "function",
inputs: [],
name: "addressProvider",
outputs: [{ name: "", internalType: "address", type: "address" }],
stateMutability: "view",
},
{
type: "function",
inputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
name: "compressorTypeToCompressor",
outputs: [{ name: "", internalType: "address", type: "address" }],
stateMutability: "view",
},
{
type: "function",
inputs: [],
Expand Down Expand Up @@ -120,7 +142,7 @@ export const iWithdrawalCompressorV310Abi = [
name: "getWithdrawalRequestResult",
outputs: [
{
name: "",
name: "withdrawal",
internalType: "struct RequestableWithdrawal",
type: "tuple",
components: [
Expand Down Expand Up @@ -151,11 +173,120 @@ export const iWithdrawalCompressorV310Abi = [
],
stateMutability: "view",
},
// TODO: REMOVE COMMENTS AFTER MIGRATION TO MULTIPLE
// {
// type: "function",
// inputs: [
// { name: "creditAccount", internalType: "address", type: "address" },
// { name: "token", internalType: "address", type: "address" },
// { name: "withdrawalToken", internalType: "address", type: "address" },
// { name: "amount", internalType: "uint256", type: "uint256" },
// ],
// name: "getWithdrawalRequestResult",
// outputs: [
// {
// name: "withdrawal",
// internalType: "struct RequestableWithdrawal",
// type: "tuple",
// components: [
// { name: "token", internalType: "address", type: "address" },
// { name: "amountIn", internalType: "uint256", type: "uint256" },
// {
// name: "outputs",
// internalType: "struct WithdrawalOutput[]",
// type: "tuple[]",
// components: [
// { name: "token", internalType: "address", type: "address" },
// { name: "isDelayed", internalType: "bool", type: "bool" },
// { name: "amount", internalType: "uint256", type: "uint256" },
// ],
// },
// {
// name: "requestCalls",
// internalType: "struct MultiCall[]",
// type: "tuple[]",
// components: [
// { name: "target", internalType: "address", type: "address" },
// { name: "callData", internalType: "bytes", type: "bytes" },
// ],
// },
// { name: "claimableAt", internalType: "uint256", type: "uint256" },
// ],
// },
// ],
// stateMutability: "view",
// },
{
type: "function",
inputs: [],
name: "owner",
outputs: [{ name: "", internalType: "address", type: "address" }],
stateMutability: "view",
},
{
type: "function",
inputs: [],
name: "renounceOwnership",
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
inputs: [
{ name: "subcompressor", internalType: "address", type: "address" },
],
name: "setSubcompressor",
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
inputs: [
{ name: "withdrawableType", internalType: "bytes32", type: "bytes32" },
{ name: "compressorType", internalType: "bytes32", type: "bytes32" },
],
name: "setWithdrawableTypeToCompressorType",
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
inputs: [{ name: "newOwner", internalType: "address", type: "address" }],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
inputs: [],
name: "version",
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
stateMutability: "view",
},
{
type: "function",
inputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
name: "withdrawableTypeToCompressorType",
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
stateMutability: "view",
},
{
type: "event",
anonymous: false,
inputs: [
{
name: "previousOwner",
internalType: "address",
type: "address",
indexed: true,
},
{
name: "newOwner",
internalType: "address",
type: "address",
indexed: true,
},
],
name: "OwnershipTransferred",
},
] as const;
14 changes: 10 additions & 4 deletions src/sdk/accounts/AbstractCreditAccountsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "../../abi/v300.js";
import type { CreditAccountData } from "../base/index.js";
import { SDKConstruct } from "../base/index.js";
import { chains } from "../chain/chains.js";
import {
ADDRESS_0X0,
AP_CREDIT_ACCOUNT_COMPRESSOR,
Expand Down Expand Up @@ -75,11 +76,14 @@ export interface CreditAccountServiceOptions {
batchSize?: number;
}

// TODO: HARDCODED
const COMPRESSORS: Record<number, Address> = {
[chains.Mainnet.id]: "0xfB79b6713fe214B8748ED7b0db1f93E4f1aC9d29",
[chains.Monad.id]: "0x36F3d0Bb73CBC2E94fE24dF0f26a689409cF9023",
};

export function getWithdrawalCompressorAddress(chainId: number) {
// TODO: HARDCODED
const compressor =
chainId === 1 ? "0xfB79b6713fe214B8748ED7b0db1f93E4f1aC9d29" : undefined;
return compressor;
return COMPRESSORS[chainId];
}

export abstract class AbstractCreditAccountService extends SDKConstruct {
Expand Down Expand Up @@ -716,6 +720,7 @@ export abstract class AbstractCreditAccountService extends SDKConstruct {
client: this.client,
});

// TODO: return multiple configs
const resp = await contract.read.getWithdrawalRequestResult([
creditAccount,
token,
Expand Down Expand Up @@ -745,6 +750,7 @@ export abstract class AbstractCreditAccountService extends SDKConstruct {
client: this.client,
});

// TODO: return multiple configs
const resp = await contract.read.getCurrentWithdrawals([creditAccount]);

const claimableNow = resp?.[0] || [];
Expand Down
Loading