Skip to content

Commit

Permalink
Fix web3 contract instances
Browse files Browse the repository at this point in the history
  • Loading branch information
germartinez committed Jul 5, 2023
1 parent cd40717 commit 342b30c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,52 @@ import { Multi_send as MultiSend_V1_3_0 } from '@safe-global/protocol-kit/typech
import { Multi_send_call_only as MultiSendCallOnly_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Multi_send_call_only'
import { Proxy_factory as SafeProxyFactory_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Proxy_factory'
import { Sign_message_lib as SignMessageLib_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Sign_message_lib'
import { Compatibility_fallback_handler as CompatibilityFallbackHandler_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Compatibility_fallback_handler'
import { Create_call as CreateCall_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Create_call'
import { Multi_send as MultiSend_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Multi_send'
import { Multi_send_call_only as MultiSendCallOnly_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Multi_send_call_only'
import { Safe as SafeMasterCopy_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Safe'
import { Safe_proxy_factory as SafeProxyFactory_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Safe_proxy_factory'
import { Sign_message_lib as SignMessageLib_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Sign_message_lib'
import { SafeVersion } from '@safe-global/safe-core-sdk-types'
import CompatibilityFallbackHandler_V1_3_0_Web3 from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Web3'
import CompatibilityFallbackHandler_V1_4_1_Web3 from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Web3'
import CreateCallContract_V1_3_0_Web3 from './CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3'
import CreateCallContract_V1_4_1_Web3 from './CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3'
import MultiSendContract_V1_1_1_Web3 from './MultiSend/v1.1.1/MultiSendContract_V1_1_1_Web3'
import MultiSendContract_V1_3_0_Web3 from './MultiSend/v1.3.0/MultiSendContract_V1_3_0_Web3'
import MultiSendContract_V1_4_1_Web3 from './MultiSend/v1.4.1/MultiSendContract_V1_4_1_Web3'
import MultiSendCallOnlyContract_V1_3_0_Web3 from './MultiSendCallOnly/v1.3.0/MultiSendCallOnlyContract_V1_3_0_Web3'
import MultiSendCallOnlyContract_V1_4_1_Web3 from './MultiSendCallOnly/v1.4.1/MultiSendCallOnlyContract_V1_4_1_Web3'
import SafeContract_V1_0_0_Web3 from './Safe/v1.0.0/SafeContract_V1_0_0_Web3'
import SafeContract_V1_1_1_Web3 from './Safe/v1.1.1/SafeContract_V1_1_1_Web3'
import SafeContract_V1_2_0_Web3 from './Safe/v1.2.0/SafeContract_V1_2_0_Web3'
import SafeContract_V1_3_0_Web3 from './Safe/v1.3.0/SafeContract_V1_3_0_Web3'
import SafeContract_V1_4_1_Web3 from './Safe/v1.4.1/SafeContract_V1_4_1_Web3'
import SafeProxyFactoryContract_V1_0_0_Web3 from './SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_V1_0_0_Web3'
import SafeProxyFactoryContract_V1_1_1_Web3 from './SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_V1_1_1_Web3'
import SafeProxyFactoryContract_V1_3_0_Web3 from './SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_V1_3_0_Web3'
import SafeProxyFactoryContract_V1_4_1_Web3 from './SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_V1_4_1_Web3'
import SignMessageLibContract_V1_3_0_Web3 from './SignMessageLib/v1.3.0/SignMessageLibContract_V1_3_0_Web3'
import SignMessageLibContract_V1_4_1_Web3 from './SignMessageLib/v1.4.1/SignMessageLibContract_V1_4_1_Web3'

export function getSafeContractInstance(
safeVersion: SafeVersion,
safeContract:
| SafeMasterCopy_V1_4_1
| SafeMasterCopy_V1_3_0
| SafeMasterCopy_V1_2_0
| SafeMasterCopy_V1_1_1
| SafeMasterCopy_V1_0_0
):
| SafeContract_V1_4_1_Web3
| SafeContract_V1_3_0_Web3
| SafeContract_V1_2_0_Web3
| SafeContract_V1_1_1_Web3
| SafeContract_V1_0_0_Web3 {
switch (safeVersion) {
case '1.4.1':
return new SafeContract_V1_4_1_Web3(safeContract as SafeMasterCopy_V1_4_1)
case '1.3.0':
return new SafeContract_V1_3_0_Web3(safeContract as SafeMasterCopy_V1_3_0)
case '1.2.0':
Expand All @@ -54,9 +72,15 @@ export function getSafeContractInstance(

export function getCompatibilityFallbackHandlerContractInstance(
safeVersion: SafeVersion,
compatibilityFallbackhandlerContract: CompatibilityFallbackHandler_V1_3_0
): CompatibilityFallbackHandler_V1_3_0_Web3 {
compatibilityFallbackhandlerContract:
| CompatibilityFallbackHandler_V1_4_1
| CompatibilityFallbackHandler_V1_3_0
): CompatibilityFallbackHandler_V1_4_1_Web3 | CompatibilityFallbackHandler_V1_3_0_Web3 {
switch (safeVersion) {
case '1.4.1':
return new CompatibilityFallbackHandler_V1_4_1_Web3(
compatibilityFallbackhandlerContract as CompatibilityFallbackHandler_V1_4_1
)
case '1.3.0':
case '1.2.0':
case '1.1.1':
Expand All @@ -70,9 +94,11 @@ export function getCompatibilityFallbackHandlerContractInstance(

export function getMultiSendContractInstance(
safeVersion: SafeVersion,
multiSendContract: MultiSend_V1_3_0 | MultiSend_V1_1_1
): MultiSendContract_V1_3_0_Web3 | MultiSendContract_V1_1_1_Web3 {
multiSendContract: MultiSend_V1_4_1 | MultiSend_V1_3_0 | MultiSend_V1_1_1
): MultiSendContract_V1_4_1_Web3 | MultiSendContract_V1_3_0_Web3 | MultiSendContract_V1_1_1_Web3 {
switch (safeVersion) {
case '1.4.1':
return new MultiSendContract_V1_4_1_Web3(multiSendContract as MultiSend_V1_4_1)
case '1.3.0':
return new MultiSendContract_V1_3_0_Web3(multiSendContract as MultiSend_V1_3_0)
case '1.2.0':
Expand All @@ -86,9 +112,13 @@ export function getMultiSendContractInstance(

export function getMultiSendCallOnlyContractInstance(
safeVersion: SafeVersion,
multiSendCallOnlyContract: MultiSendCallOnly_V1_3_0
): MultiSendCallOnlyContract_V1_3_0_Web3 {
multiSendCallOnlyContract: MultiSendCallOnly_V1_4_1 | MultiSendCallOnly_V1_3_0
): MultiSendCallOnlyContract_V1_4_1_Web3 | MultiSendCallOnlyContract_V1_3_0_Web3 {
switch (safeVersion) {
case '1.4.1':
return new MultiSendCallOnlyContract_V1_4_1_Web3(
multiSendCallOnlyContract as MultiSendCallOnly_V1_4_1
)
case '1.3.0':
case '1.2.0':
case '1.1.1':
Expand All @@ -104,14 +134,20 @@ export function getMultiSendCallOnlyContractInstance(
export function getSafeProxyFactoryContractInstance(
safeVersion: SafeVersion,
safeProxyFactoryContract:
| SafeProxyFactory_V1_4_1
| SafeProxyFactory_V1_3_0
| SafeProxyFactory_V1_1_1
| SafeProxyFactoryContract_V1_0_0_Web3
| SafeProxyFactory_V1_0_0
):
| SafeProxyFactoryContract_V1_4_1_Web3
| SafeProxyFactoryContract_V1_3_0_Web3
| SafeProxyFactoryContract_V1_1_1_Web3
| SafeProxyFactoryContract_V1_0_0_Web3 {
switch (safeVersion) {
case '1.4.1':
return new SafeProxyFactoryContract_V1_4_1_Web3(
safeProxyFactoryContract as SafeProxyFactory_V1_4_1
)
case '1.3.0':
return new SafeProxyFactoryContract_V1_3_0_Web3(
safeProxyFactoryContract as SafeProxyFactory_V1_3_0
Expand All @@ -132,9 +168,11 @@ export function getSafeProxyFactoryContractInstance(

export function getSignMessageLibContractInstance(
safeVersion: SafeVersion,
signMessageLibContract: SignMessageLib_V1_3_0
): SignMessageLibContract_V1_3_0_Web3 {
signMessageLibContract: SignMessageLib_V1_4_1 | SignMessageLib_V1_3_0
): SignMessageLibContract_V1_4_1_Web3 | SignMessageLibContract_V1_3_0_Web3 {
switch (safeVersion) {
case '1.4.1':
return new SignMessageLibContract_V1_4_1_Web3(signMessageLibContract as SignMessageLib_V1_4_1)
case '1.3.0':
return new SignMessageLibContract_V1_3_0_Web3(signMessageLibContract as SignMessageLib_V1_3_0)
default:
Expand All @@ -144,9 +182,11 @@ export function getSignMessageLibContractInstance(

export function getCreateCallContractInstance(
safeVersion: SafeVersion,
createCallContract: CreateCall_V1_3_0
): CreateCallContract_V1_3_0_Web3 {
createCallContract: CreateCall_V1_4_1 | CreateCall_V1_3_0
): CreateCallContract_V1_4_1_Web3 | CreateCallContract_V1_3_0_Web3 {
switch (safeVersion) {
case '1.4.1':
return new CreateCallContract_V1_4_1_Web3(createCallContract as CreateCall_V1_4_1)
case '1.3.0':
case '1.2.0':
case '1.1.1':
Expand Down
15 changes: 1 addition & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3415,11 +3415,6 @@
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.1.tgz#2f4f65bb08bc368ac39c96da7b2f09140b26851b"
integrity sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==

"@types/mocha@^9.1.1":
version "9.1.1"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4"
integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==

"@types/node-fetch@^2.6.1":
version "2.6.3"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.3.tgz#175d977f5e24d93ad0f57602693c435c57ad7e80"
Expand Down Expand Up @@ -4625,14 +4620,6 @@ axios@^0.21.1:
dependencies:
follow-redirects "^1.14.0"

axios@^0.27.2:
version "0.27.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
dependencies:
follow-redirects "^1.14.9"
form-data "^4.0.0"

axios@^1.0.0:
version "1.3.5"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.5.tgz#e07209b39a0d11848e3e341fa087acd71dadc542"
Expand Down Expand Up @@ -7451,7 +7438,7 @@ fmix@^0.1.0:
dependencies:
imul "^1.0.0"

follow-redirects@^1.12.1, follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.14.9, follow-redirects@^1.15.0:
follow-redirects@^1.12.1, follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
Expand Down

0 comments on commit 342b30c

Please sign in to comment.