Skip to content

Commit

Permalink
fix: add admin to upgradeable contract
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulgalimov committed May 29, 2024
1 parent 3487453 commit 8570f0f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unique-marketplace-backend",
"version": "3.0.262",
"version": "3.0.263",
"description": "Backend project for unique marketplace",
"author": "Unique Network",
"private": true,
Expand Down
33 changes: 28 additions & 5 deletions packages/contracts/scripts/deploy-upgradeable-market.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@

import { ethers, upgrades } from 'hardhat';
import { KeyringProvider } from '@unique-nft/accounts/keyring';
import { Market } from '../typechain-types';
import { Address } from '@unique-nft/utils';

const seed = process.env.SUBSTRATE_SIGNER_SEED!;

async function main() {
const Market = await ethers.getContractFactory('Market');
const MarketFactory = await ethers.getContractFactory('Market');

console.log('Deploying Market...');
const box = await upgrades.deployProxy(Market, [0], {
const contract = await upgrades.deployProxy(MarketFactory, [0], {
initializer: 'initialize',
txOverrides: {
gasLimit: 7000000,
},
});

await box.waitForDeployment();
console.log('Market deployed to:', await box.getAddress());
await contract.waitForDeployment();
console.log('Market deployed to:', await contract.getAddress());

await addAdmin(contract as unknown as Market);
}

async function addAdmin(market: Market) {
console.log('adding admin to contract');
const provider = new KeyringProvider({
type: 'sr25519',
});
const signer = provider.addSeed(seed);
const address = signer.address;
const ethAddress = Address.mirror.substrateToEthereum(address);

const tx = await market.addAdmin(ethAddress, {
gasLimit: 7_000_000,
});
await tx.wait();

console.log(`added admin sub: ${address}, eth: ${ethAddress}`);
}

main();

0 comments on commit 8570f0f

Please sign in to comment.