Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add task to propose proxy upgrades to safe wallet #35

Merged
merged 5 commits into from
Feb 26, 2024
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
16 changes: 15 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = {
FORWARDER_ON_GNOSIS: '0x49157Ddc1cA1907AC7b1f6e871Aa90e93567aDa4',
PNT_ON_GNOSIS_ADDRESS: '0x0259461eed4d76d4f0f900f9035f6c4dfb39159a',
DAOPNT_ON_GNOSIS_ADDRESS: '0xFF8Ce5Aca26251Cc3f31e597291c71794C06092a',
TOKEN_MANAGER_ADDRESS: '0xCec0058735D50de98d3715792569921FEb9EfDC1'
TOKEN_MANAGER_ADDRESS: '0xCec0058735D50de98d3715792569921FEb9EfDC1',
PNT_ON_GNOSIS_MINTER: '0x53d51f8801f40657ca566a1ae25b27eada97413c'
},
POLYGON: {
PNT_ON_POLYGON_ADDRESS: '0xb6bcae6468760bc0cdfb9c8ef4ee75c9dd23e1ed',
Expand Down Expand Up @@ -68,5 +69,18 @@ module.exports = {
ONE_DAY: 86400,
ONE_MONTH: 86400 * 30,
INFINITE: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
},
TASKS: {
PARAM_NAME_ADDRESS: 'address',
PARAM_NAME_ENTITY: 'entity',
PARAM_NAME_FACTORY: 'factory',
PARAM_FLAG_NEW_IMPLEMENTATION: 'implementation',
PARAM_FLAG_LEDGER_WALLET: 'ledger',
PARAM_NAME_PROXY_ADDRESS: 'proxy',
PARAM_NAME_ROLE: 'role',
PARAM_NAME_SAFE_ADDRESS: 'safe',
PARAM_NAME_TARGET: 'target',
PARAM_NAME_REVOKE: 'revoke',
PARAM_NAME_GRANT: 'grant'
}
}
32 changes: 32 additions & 0 deletions lib/safe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { LedgerSigner } = require('@ethersproject/hardware-wallets')
const SafeApiKit = require('@safe-global/api-kit').default
const Safe = require('@safe-global/protocol-kit').default
const { EthersAdapter } = require('@safe-global/protocol-kit')

module.exports.proposeTransactionToSafe = async (_adapter, _safeAddress, _to, _value, _data) => {
const safe = await Safe.create({ ethAdapter: _adapter, safeAddress: _safeAddress })
const safeTransactionData = {
to: _to,
value: _value,
data: _data
}
const safeTransaction = await safe.createTransaction({ transactions: [safeTransactionData] })
const safeTxHash = await safe.getTransactionHash(safeTransaction)
const senderSignature = await safe.signHash(safeTxHash)
const safeService = new SafeApiKit({ chainId: await _adapter.getChainId() })
await safeService.proposeTransaction({
safeAddress: _safeAddress,
safeTransactionData: safeTransaction.data,
safeTxHash,
senderAddress: await _adapter.getSignerAddress(),
senderSignature: senderSignature.data
})
}

module.exports.getAdapter = async (_ethers, _ledger = false) => {
const signer = _ledger ? new LedgerSigner(_ethers.provider) : await _ethers.provider.getSigner()
return new EthersAdapter({
ethers: _ethers,
signerOrProvider: signer
})
}
Loading