@obolnetwork/obol-sdk 2.8.0 → 2.8.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/cjs/package.json +2 -4
- package/dist/cjs/src/abi/splitV2FactoryAbi.js +420 -0
- package/dist/cjs/src/bytecodes.js +3 -1
- package/dist/cjs/src/constants.js +24 -16
- package/dist/cjs/src/index.js +10 -10
- package/dist/cjs/src/schema.js +1 -2
- package/dist/cjs/src/splits/splitHelpers.js +77 -109
- package/dist/cjs/src/splits/splits.js +38 -16
- package/dist/cjs/test/splits/splits.spec.js +2 -2
- package/dist/esm/package.json +2 -4
- package/dist/esm/src/abi/splitV2FactoryAbi.js +417 -0
- package/dist/esm/src/bytecodes.js +2 -0
- package/dist/esm/src/constants.js +25 -17
- package/dist/esm/src/index.js +10 -10
- package/dist/esm/src/schema.js +1 -2
- package/dist/esm/src/splits/splitHelpers.js +78 -109
- package/dist/esm/src/splits/splits.js +38 -16
- package/dist/esm/test/splits/splits.spec.js +2 -2
- package/dist/types/src/abi/splitV2FactoryAbi.d.ts +60 -0
- package/dist/types/src/bytecodes.d.ts +2 -0
- package/dist/types/src/exits/verificationHelpers.d.ts +1 -0
- package/dist/types/src/schema.d.ts +3 -3
- package/dist/types/src/splits/splitHelpers.d.ts +1 -3
- package/dist/types/src/types.d.ts +10 -6
- package/dist/types/src/verification/common.d.ts +1 -0
- package/package.json +2 -4
- package/src/abi/splitV2FactoryAbi.ts +417 -0
- package/src/bytecodes.ts +4 -0
- package/src/constants.ts +26 -16
- package/src/index.ts +14 -14
- package/src/schema.ts +1 -2
- package/src/splits/splitHelpers.ts +132 -123
- package/src/splits/splits.ts +68 -17
- package/src/types.ts +10 -6
|
@@ -8,27 +8,18 @@ import {
|
|
|
8
8
|
type OVMArgs,
|
|
9
9
|
type ChainConfig,
|
|
10
10
|
} from '../types';
|
|
11
|
-
import {
|
|
12
|
-
BrowserProvider,
|
|
13
|
-
Contract,
|
|
14
|
-
Interface,
|
|
15
|
-
parseEther,
|
|
16
|
-
type Wallet,
|
|
17
|
-
ZeroAddress,
|
|
18
|
-
} from 'ethers';
|
|
11
|
+
import { Contract, Interface, parseEther, ZeroAddress } from 'ethers';
|
|
19
12
|
import { OWRContract, OWRFactoryContract } from '../abi/OWR';
|
|
20
13
|
import { OVMFactoryContract } from '../abi/OVMFactory';
|
|
21
14
|
import { splitMainEthereumAbi } from '../abi/SplitMain';
|
|
22
15
|
import { MultiCallContract } from '../abi/Multicall';
|
|
23
|
-
import { CHAIN_CONFIGURATION
|
|
24
|
-
import {
|
|
25
|
-
import { createPublicClient, createWalletClient, custom, http } from 'viem';
|
|
26
|
-
import { hoodi, mainnet } from 'viem/chains';
|
|
27
|
-
import { privateKeyToAccount } from 'viem/accounts';
|
|
16
|
+
import { CHAIN_CONFIGURATION } from '../constants';
|
|
17
|
+
import { splitV2FactoryAbi } from '../abi/splitV2FactoryAbi';
|
|
28
18
|
|
|
29
19
|
const splitMainContractInterface = new Interface(splitMainEthereumAbi);
|
|
30
20
|
const owrFactoryContractInterface = new Interface(OWRFactoryContract.abi);
|
|
31
21
|
const ovmFactoryContractInterface = new Interface(OVMFactoryContract.abi);
|
|
22
|
+
const splitV2FactoryInterface = new Interface(splitV2FactoryAbi);
|
|
32
23
|
|
|
33
24
|
type Call = {
|
|
34
25
|
target: ETH_ADDRESS;
|
|
@@ -104,7 +95,7 @@ export const predictSplitterAddress = async ({
|
|
|
104
95
|
}): Promise<ETH_ADDRESS> => {
|
|
105
96
|
try {
|
|
106
97
|
const splitMainContractInstance = new Contract(
|
|
107
|
-
getChainConfig(chainId).
|
|
98
|
+
getChainConfig(chainId).SPLITMAIN_CONTRACT.address,
|
|
108
99
|
splitMainEthereumAbi,
|
|
109
100
|
signer,
|
|
110
101
|
);
|
|
@@ -258,7 +249,7 @@ const createOWRContract = async ({
|
|
|
258
249
|
}): Promise<ETH_ADDRESS> => {
|
|
259
250
|
try {
|
|
260
251
|
const OWRFactoryInstance = new Contract(
|
|
261
|
-
getChainConfig(chainId).
|
|
252
|
+
getChainConfig(chainId).OWR_FACTORY_CONTRACT.address,
|
|
262
253
|
OWRFactoryContract.abi,
|
|
263
254
|
signer,
|
|
264
255
|
);
|
|
@@ -345,7 +336,7 @@ export const deploySplitterContract = async ({
|
|
|
345
336
|
}): Promise<ETH_ADDRESS> => {
|
|
346
337
|
try {
|
|
347
338
|
const splitMainContractInstance = new Contract(
|
|
348
|
-
getChainConfig(chainId).
|
|
339
|
+
getChainConfig(chainId).SPLITMAIN_CONTRACT.address,
|
|
349
340
|
splitMainEthereumAbi,
|
|
350
341
|
signer,
|
|
351
342
|
);
|
|
@@ -444,21 +435,16 @@ export const deploySplitterAndOWRContracts = async ({
|
|
|
444
435
|
|
|
445
436
|
executeCalls.push(
|
|
446
437
|
{
|
|
447
|
-
target: getChainConfig(chainId).
|
|
438
|
+
target: getChainConfig(chainId).SPLITMAIN_CONTRACT.address,
|
|
448
439
|
callData: splitTxData,
|
|
449
440
|
},
|
|
450
441
|
{
|
|
451
|
-
target: getChainConfig(chainId).
|
|
442
|
+
target: getChainConfig(chainId).OWR_FACTORY_CONTRACT.address,
|
|
452
443
|
callData: owrTxData,
|
|
453
444
|
},
|
|
454
445
|
);
|
|
455
|
-
const multicallAddess = getChainConfig(chainId).MULTICALL_ADDRESS.address;
|
|
456
446
|
|
|
457
|
-
const executeMultiCalls = await multicall(
|
|
458
|
-
executeCalls,
|
|
459
|
-
signer,
|
|
460
|
-
multicallAddess,
|
|
461
|
-
);
|
|
447
|
+
const executeMultiCalls = await multicall(executeCalls, signer, chainId);
|
|
462
448
|
|
|
463
449
|
const splitAddressData = executeMultiCalls?.logs[0]?.topics[1];
|
|
464
450
|
const formattedSplitterAddress = '0x' + splitAddressData?.slice(26, 66);
|
|
@@ -519,9 +505,11 @@ export const getOWRTranches = async ({
|
|
|
519
505
|
export const multicall = async (
|
|
520
506
|
calls: Call[],
|
|
521
507
|
signer: SignerType,
|
|
522
|
-
|
|
508
|
+
chainId: number,
|
|
523
509
|
): Promise<any> => {
|
|
524
510
|
try {
|
|
511
|
+
const chainConfig = getChainConfig(chainId);
|
|
512
|
+
const multicallAddress = chainConfig.MULTICALL_CONTRACT.address;
|
|
525
513
|
const multiCallContractInstance = new Contract(
|
|
526
514
|
multicallAddress,
|
|
527
515
|
MultiCallContract.abi,
|
|
@@ -613,57 +601,31 @@ export const formatRecipientsForSplitV2 = (
|
|
|
613
601
|
}));
|
|
614
602
|
};
|
|
615
603
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
)
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
chain,
|
|
635
|
-
transport: custom((window as any).ethereum),
|
|
636
|
-
});
|
|
637
|
-
return new SplitsClient({
|
|
638
|
-
publicClient: client,
|
|
639
|
-
walletClient: viemWalletClient,
|
|
640
|
-
chainId,
|
|
641
|
-
});
|
|
642
|
-
} else {
|
|
643
|
-
// For non-browser environment, extract private key from signer
|
|
644
|
-
const signerPrivateKey = (signer as Wallet)?.privateKey;
|
|
645
|
-
if (!signerPrivateKey) {
|
|
646
|
-
throw new Error('Signer private key not available');
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
const privateKey = signerPrivateKey.startsWith('0x')
|
|
650
|
-
? signerPrivateKey
|
|
651
|
-
: `0x${signerPrivateKey}`;
|
|
652
|
-
|
|
653
|
-
const scriptAccount = privateKeyToAccount(privateKey as `0x${string}`);
|
|
654
|
-
const account = scriptAccount;
|
|
604
|
+
// Helper function to create SplitV2 parameters
|
|
605
|
+
const createSplitV2Params = (
|
|
606
|
+
recipients: SplitV2Recipient[],
|
|
607
|
+
distributorFeePercent: number,
|
|
608
|
+
): {
|
|
609
|
+
recipients: string[];
|
|
610
|
+
allocations: number[];
|
|
611
|
+
totalAllocation: number;
|
|
612
|
+
distributionIncentive: number;
|
|
613
|
+
} => {
|
|
614
|
+
const addresses = recipients.map(r => r.address);
|
|
615
|
+
const allocations = recipients.map(r =>
|
|
616
|
+
Math.floor(r.percentAllocation * 1e4),
|
|
617
|
+
); // Convert to basis points
|
|
618
|
+
const totalAllocation = allocations.reduce(
|
|
619
|
+
(sum, allocation) => sum + allocation,
|
|
620
|
+
0,
|
|
621
|
+
);
|
|
655
622
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
publicClient: client,
|
|
663
|
-
walletClient: viemWalletClient,
|
|
664
|
-
chainId,
|
|
665
|
-
});
|
|
666
|
-
}
|
|
623
|
+
return {
|
|
624
|
+
recipients: addresses,
|
|
625
|
+
allocations,
|
|
626
|
+
totalAllocation,
|
|
627
|
+
distributionIncentive: distributorFeePercent,
|
|
628
|
+
};
|
|
667
629
|
};
|
|
668
630
|
|
|
669
631
|
export const predictSplitV2Address = async ({
|
|
@@ -682,19 +644,27 @@ export const predictSplitV2Address = async ({
|
|
|
682
644
|
chainId: number;
|
|
683
645
|
}): Promise<string> => {
|
|
684
646
|
try {
|
|
685
|
-
const
|
|
647
|
+
const chainConfig = getChainConfig(chainId);
|
|
648
|
+
if (!chainConfig?.SPLIT_V2_FACTORY_CONTRACT?.address) {
|
|
649
|
+
throw new Error(`SplitV2 Factory not configured for chain ${chainId}`);
|
|
650
|
+
}
|
|
686
651
|
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
652
|
+
const splitV2FactoryContract = new Contract(
|
|
653
|
+
chainConfig.SPLIT_V2_FACTORY_CONTRACT.address,
|
|
654
|
+
splitV2FactoryAbi,
|
|
655
|
+
signer,
|
|
656
|
+
);
|
|
657
|
+
|
|
658
|
+
const splitParams = createSplitV2Params(recipients, distributorFeePercent);
|
|
693
659
|
|
|
694
|
-
|
|
660
|
+
const predictedAddress = await splitV2FactoryContract[
|
|
661
|
+
'predictDeterministicAddress((address[],uint256[],uint256,uint16),address,bytes32)'
|
|
662
|
+
](splitParams, splitOwnerAddress, salt);
|
|
663
|
+
|
|
664
|
+
return predictedAddress;
|
|
695
665
|
} catch (error: any) {
|
|
696
666
|
throw new Error(
|
|
697
|
-
`Failed to predict SplitV2 address: ${error.message ?? 'SplitV2
|
|
667
|
+
`Failed to predict SplitV2 address: ${error.message ?? 'SplitV2 contract call failed'}`,
|
|
698
668
|
);
|
|
699
669
|
}
|
|
700
670
|
};
|
|
@@ -715,15 +685,26 @@ export const isSplitV2Deployed = async ({
|
|
|
715
685
|
chainId: number;
|
|
716
686
|
}): Promise<boolean> => {
|
|
717
687
|
try {
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
688
|
+
const chainConfig = getChainConfig(chainId);
|
|
689
|
+
if (!chainConfig?.SPLIT_V2_FACTORY_CONTRACT?.address) {
|
|
690
|
+
throw new Error(`SplitV2 Factory not configured for chain ${chainId}`);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const splitV2FactoryContract = new Contract(
|
|
694
|
+
chainConfig.SPLIT_V2_FACTORY_CONTRACT.address,
|
|
695
|
+
splitV2FactoryAbi,
|
|
696
|
+
signer,
|
|
697
|
+
);
|
|
698
|
+
|
|
699
|
+
const splitParams = createSplitV2Params(recipients, distributorFeePercent);
|
|
700
|
+
|
|
701
|
+
const [, exists] = await splitV2FactoryContract.isDeployed(
|
|
702
|
+
splitParams,
|
|
703
|
+
splitOwnerAddress,
|
|
723
704
|
salt,
|
|
724
|
-
|
|
705
|
+
);
|
|
725
706
|
|
|
726
|
-
return
|
|
707
|
+
return exists;
|
|
727
708
|
} catch (error: any) {
|
|
728
709
|
// If the check fails, assume it's not deployed
|
|
729
710
|
return false;
|
|
@@ -747,12 +728,12 @@ export const deployOVMContract = async ({
|
|
|
747
728
|
}): Promise<string> => {
|
|
748
729
|
try {
|
|
749
730
|
const chainConfig = getChainConfig(chainId);
|
|
750
|
-
if (!chainConfig?.
|
|
731
|
+
if (!chainConfig?.OVM_FACTORY_CONTRACT?.address) {
|
|
751
732
|
throw new Error(`OVM Factory not configured for chain ${chainId}`);
|
|
752
733
|
}
|
|
753
734
|
|
|
754
735
|
const ovmFactoryContract = new Contract(
|
|
755
|
-
chainConfig.
|
|
736
|
+
chainConfig.OVM_FACTORY_CONTRACT.address,
|
|
756
737
|
OVMFactoryContract.abi,
|
|
757
738
|
signer,
|
|
758
739
|
);
|
|
@@ -806,36 +787,49 @@ export const deployOVMAndSplitV2 = async ({
|
|
|
806
787
|
}): Promise<string> => {
|
|
807
788
|
try {
|
|
808
789
|
const chainConfig = getChainConfig(chainId);
|
|
809
|
-
if (!chainConfig?.
|
|
790
|
+
if (!chainConfig?.OVM_FACTORY_CONTRACT?.address) {
|
|
810
791
|
throw new Error(`OVM Factory not configured for chain ${chainId}`);
|
|
811
792
|
}
|
|
812
793
|
|
|
813
|
-
|
|
814
|
-
|
|
794
|
+
if (!chainConfig?.SPLIT_V2_FACTORY_CONTRACT?.address) {
|
|
795
|
+
throw new Error(`SplitV2 Factory not configured for chain ${chainId}`);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
const executeCalls: Call[] = [];
|
|
815
799
|
|
|
816
800
|
if (rewardRecipients && !isRewardsSplitterDeployed) {
|
|
817
801
|
// Create rewards split call data
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
802
|
+
const splitParams = createSplitV2Params(
|
|
803
|
+
rewardRecipients,
|
|
804
|
+
distributorFeePercent,
|
|
805
|
+
);
|
|
806
|
+
const rewardsSplitTxData = encodeCreateSplitV2DeterministicTxData(
|
|
807
|
+
splitParams,
|
|
808
|
+
splitOwnerAddress,
|
|
809
|
+
salt,
|
|
810
|
+
);
|
|
825
811
|
|
|
826
|
-
executeCalls.push(
|
|
812
|
+
executeCalls.push({
|
|
813
|
+
target: chainConfig.SPLIT_V2_FACTORY_CONTRACT.address,
|
|
814
|
+
callData: rewardsSplitTxData,
|
|
815
|
+
});
|
|
827
816
|
}
|
|
828
817
|
|
|
829
818
|
// Create principal split call data if needed (for total split scenario)
|
|
830
819
|
if (principalSplitRecipients && !isPrincipalSplitDeployed) {
|
|
831
|
-
const
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
820
|
+
const principalSplitParams = createSplitV2Params(
|
|
821
|
+
principalSplitRecipients,
|
|
822
|
+
distributorFeePercent,
|
|
823
|
+
);
|
|
824
|
+
const principalSplitTxData = encodeCreateSplitV2DeterministicTxData(
|
|
825
|
+
principalSplitParams,
|
|
826
|
+
splitOwnerAddress,
|
|
827
|
+
salt,
|
|
828
|
+
);
|
|
829
|
+
executeCalls.push({
|
|
830
|
+
target: chainConfig.SPLIT_V2_FACTORY_CONTRACT.address,
|
|
831
|
+
callData: principalSplitTxData,
|
|
832
|
+
});
|
|
839
833
|
}
|
|
840
834
|
|
|
841
835
|
// Create OVM call data
|
|
@@ -847,25 +841,23 @@ export const deployOVMAndSplitV2 = async ({
|
|
|
847
841
|
);
|
|
848
842
|
|
|
849
843
|
executeCalls.push({
|
|
850
|
-
|
|
851
|
-
|
|
844
|
+
target: chainConfig.OVM_FACTORY_CONTRACT.address,
|
|
845
|
+
callData: ovmTxData,
|
|
852
846
|
});
|
|
853
847
|
|
|
854
848
|
// Execute multicall
|
|
855
|
-
const executeMultiCalls = await
|
|
856
|
-
calls: executeCalls,
|
|
857
|
-
});
|
|
849
|
+
const executeMultiCalls = await multicall(executeCalls, signer, chainId);
|
|
858
850
|
|
|
859
851
|
// Extract addresses from events
|
|
860
852
|
let ovmAddress: string | undefined;
|
|
861
|
-
const
|
|
853
|
+
const logsCount = executeMultiCalls?.logs?.length || 0;
|
|
862
854
|
|
|
863
|
-
if (
|
|
864
|
-
ovmAddress = executeMultiCalls?.
|
|
865
|
-
} else if (
|
|
866
|
-
ovmAddress = executeMultiCalls?.
|
|
855
|
+
if (logsCount === 2) {
|
|
856
|
+
ovmAddress = '0x' + executeMultiCalls?.logs[1]?.topics[1]?.slice(26, 66);
|
|
857
|
+
} else if (logsCount === 5) {
|
|
858
|
+
ovmAddress = '0x' + executeMultiCalls?.logs[4]?.topics[1]?.slice(26, 66);
|
|
867
859
|
} else {
|
|
868
|
-
ovmAddress = executeMultiCalls?.
|
|
860
|
+
ovmAddress = '0x' + executeMultiCalls?.logs[7]?.topics[1]?.slice(26, 66);
|
|
869
861
|
}
|
|
870
862
|
if (!ovmAddress) {
|
|
871
863
|
throw new Error(
|
|
@@ -893,6 +885,23 @@ const encodeCreateOVMTxData = (
|
|
|
893
885
|
);
|
|
894
886
|
};
|
|
895
887
|
|
|
888
|
+
const encodeCreateSplitV2DeterministicTxData = (
|
|
889
|
+
splitParams: {
|
|
890
|
+
recipients: string[];
|
|
891
|
+
allocations: number[];
|
|
892
|
+
totalAllocation: number;
|
|
893
|
+
distributionIncentive: number;
|
|
894
|
+
},
|
|
895
|
+
splitOwnerAddress: string,
|
|
896
|
+
salt: `0x${string}`,
|
|
897
|
+
): string => {
|
|
898
|
+
// creatorAddress can be kept as default https://docs.splits.org/sdk/splits-v2#createsplit
|
|
899
|
+
return splitV2FactoryInterface.encodeFunctionData(
|
|
900
|
+
'createSplitDeterministic',
|
|
901
|
+
[splitParams, splitOwnerAddress, ZeroAddress, salt],
|
|
902
|
+
);
|
|
903
|
+
};
|
|
904
|
+
|
|
896
905
|
// Helper function to safely get chain configuration
|
|
897
906
|
const getChainConfig = (chainId: number): ChainConfig => {
|
|
898
907
|
const config = CHAIN_CONFIGURATION[chainId];
|
package/src/splits/splits.ts
CHANGED
|
@@ -87,7 +87,7 @@ export class ObolSplits {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const chainConfig = CHAIN_CONFIGURATION[this.chainId];
|
|
90
|
-
if (!chainConfig?.
|
|
90
|
+
if (!chainConfig?.OVM_FACTORY_CONTRACT) {
|
|
91
91
|
throw new Error(
|
|
92
92
|
`OVM contract factory is not configured for chain ${this.chainId}`,
|
|
93
93
|
);
|
|
@@ -98,28 +98,53 @@ export class ObolSplits {
|
|
|
98
98
|
'Provider is required to check OVM factory contract availability',
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
101
|
+
const ovmFactoryConfig = chainConfig.OVM_FACTORY_CONTRACT;
|
|
102
|
+
const splitV2FactoryConfig = chainConfig.SPLIT_V2_FACTORY_CONTRACT;
|
|
103
|
+
const multiCallConfig = chainConfig.MULTICALL_CONTRACT;
|
|
104
|
+
|
|
105
|
+
if (
|
|
106
|
+
!ovmFactoryConfig?.address ||
|
|
107
|
+
!ovmFactoryConfig?.bytecode ||
|
|
108
|
+
!splitV2FactoryConfig?.address ||
|
|
109
|
+
!splitV2FactoryConfig?.bytecode ||
|
|
110
|
+
!multiCallConfig?.address ||
|
|
111
|
+
!multiCallConfig?.bytecode
|
|
112
|
+
) {
|
|
104
113
|
throw new Error(
|
|
105
|
-
`
|
|
114
|
+
`Contracts configuration is incomplete for chain ${this.chainId}`,
|
|
106
115
|
);
|
|
107
116
|
}
|
|
108
117
|
|
|
109
|
-
const
|
|
118
|
+
const checkOVMFactoryContract = await isContractAvailable(
|
|
110
119
|
ovmFactoryConfig.address,
|
|
111
120
|
this.provider,
|
|
112
121
|
ovmFactoryConfig.bytecode,
|
|
113
122
|
);
|
|
114
123
|
|
|
115
|
-
|
|
124
|
+
const checkSplitV2FactoryContract = await isContractAvailable(
|
|
125
|
+
splitV2FactoryConfig.address,
|
|
126
|
+
this.provider,
|
|
127
|
+
splitV2FactoryConfig.bytecode,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const checkMultiCallContract = await isContractAvailable(
|
|
131
|
+
multiCallConfig.address,
|
|
132
|
+
this.provider,
|
|
133
|
+
multiCallConfig.bytecode,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
if (
|
|
137
|
+
!checkOVMFactoryContract ||
|
|
138
|
+
!checkSplitV2FactoryContract ||
|
|
139
|
+
!checkMultiCallContract
|
|
140
|
+
) {
|
|
116
141
|
throw new Error(
|
|
117
|
-
`
|
|
142
|
+
`Splitter contract is not deployed or available on chain ${this.chainId}`,
|
|
118
143
|
);
|
|
119
144
|
}
|
|
120
145
|
|
|
121
146
|
const retroActiveFundingRecipient = {
|
|
122
|
-
address: chainConfig.
|
|
147
|
+
address: chainConfig.RETROACTIVE_FUNDING_CONTRACT.address,
|
|
123
148
|
percentAllocation: DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT,
|
|
124
149
|
};
|
|
125
150
|
|
|
@@ -228,7 +253,7 @@ export class ObolSplits {
|
|
|
228
253
|
}
|
|
229
254
|
|
|
230
255
|
const chainConfig = CHAIN_CONFIGURATION[this.chainId];
|
|
231
|
-
if (!chainConfig?.
|
|
256
|
+
if (!chainConfig?.OVM_FACTORY_CONTRACT) {
|
|
232
257
|
throw new Error(
|
|
233
258
|
`OVM contract factory is not configured for chain ${this.chainId}`,
|
|
234
259
|
);
|
|
@@ -240,27 +265,53 @@ export class ObolSplits {
|
|
|
240
265
|
);
|
|
241
266
|
}
|
|
242
267
|
|
|
243
|
-
const ovmFactoryConfig = chainConfig.
|
|
244
|
-
|
|
268
|
+
const ovmFactoryConfig = chainConfig.OVM_FACTORY_CONTRACT;
|
|
269
|
+
const splitV2FactoryConfig = chainConfig.SPLIT_V2_FACTORY_CONTRACT;
|
|
270
|
+
const multiCallConfig = chainConfig.MULTICALL_CONTRACT;
|
|
271
|
+
|
|
272
|
+
if (
|
|
273
|
+
!ovmFactoryConfig?.address ||
|
|
274
|
+
!ovmFactoryConfig?.bytecode ||
|
|
275
|
+
!splitV2FactoryConfig?.address ||
|
|
276
|
+
!splitV2FactoryConfig?.bytecode ||
|
|
277
|
+
!multiCallConfig?.address ||
|
|
278
|
+
!multiCallConfig?.bytecode
|
|
279
|
+
) {
|
|
245
280
|
throw new Error(
|
|
246
|
-
`
|
|
281
|
+
`Contracts configuration is incomplete for chain ${this.chainId}`,
|
|
247
282
|
);
|
|
248
283
|
}
|
|
249
284
|
|
|
250
|
-
const
|
|
285
|
+
const checkOVMFactoryContract = await isContractAvailable(
|
|
251
286
|
ovmFactoryConfig.address,
|
|
252
287
|
this.provider,
|
|
253
288
|
ovmFactoryConfig.bytecode,
|
|
254
289
|
);
|
|
255
290
|
|
|
256
|
-
|
|
291
|
+
const checkSplitV2FactoryContract = await isContractAvailable(
|
|
292
|
+
splitV2FactoryConfig.address,
|
|
293
|
+
this.provider,
|
|
294
|
+
splitV2FactoryConfig.bytecode,
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
const checkMultiCallContract = await isContractAvailable(
|
|
298
|
+
multiCallConfig.address,
|
|
299
|
+
this.provider,
|
|
300
|
+
multiCallConfig.bytecode,
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
if (
|
|
304
|
+
!checkOVMFactoryContract ||
|
|
305
|
+
!checkSplitV2FactoryContract ||
|
|
306
|
+
!checkMultiCallContract
|
|
307
|
+
) {
|
|
257
308
|
throw new Error(
|
|
258
|
-
`
|
|
309
|
+
`Splitter contract is not deployed or available on chain ${this.chainId}`,
|
|
259
310
|
);
|
|
260
311
|
}
|
|
261
312
|
|
|
262
313
|
const retroActiveFundingRecipient = {
|
|
263
|
-
address: chainConfig.
|
|
314
|
+
address: chainConfig.RETROACTIVE_FUNDING_CONTRACT.address,
|
|
264
315
|
percentAllocation: DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT,
|
|
265
316
|
};
|
|
266
317
|
|
package/src/types.ts
CHANGED
|
@@ -578,27 +578,31 @@ export type OVMArgs = {
|
|
|
578
578
|
};
|
|
579
579
|
|
|
580
580
|
export type ChainConfig = {
|
|
581
|
-
|
|
581
|
+
SPLITMAIN_CONTRACT: {
|
|
582
582
|
address: string;
|
|
583
583
|
bytecode: string;
|
|
584
584
|
};
|
|
585
|
-
|
|
585
|
+
MULTICALL_CONTRACT: {
|
|
586
586
|
address: string;
|
|
587
587
|
bytecode: string;
|
|
588
588
|
};
|
|
589
|
-
|
|
589
|
+
OWR_FACTORY_CONTRACT: {
|
|
590
590
|
address: string;
|
|
591
591
|
bytecode: string;
|
|
592
592
|
};
|
|
593
|
-
|
|
593
|
+
RETROACTIVE_FUNDING_CONTRACT: {
|
|
594
594
|
address: string;
|
|
595
595
|
bytecode: string;
|
|
596
596
|
};
|
|
597
|
-
|
|
597
|
+
OVM_FACTORY_CONTRACT?: {
|
|
598
598
|
address: string;
|
|
599
599
|
bytecode: string;
|
|
600
600
|
};
|
|
601
|
-
|
|
601
|
+
WAREHOUSE_CONTRACT?: {
|
|
602
|
+
address: string;
|
|
603
|
+
bytecode: string;
|
|
604
|
+
};
|
|
605
|
+
SPLIT_V2_FACTORY_CONTRACT?: {
|
|
602
606
|
address: string;
|
|
603
607
|
bytecode: string;
|
|
604
608
|
};
|