Skip to content

Commit

Permalink
Upgrade/exchange contract (#251)
Browse files Browse the repository at this point in the history
* Add moduleAlias to avoid local error

* Upgrade testnet

* Create new internal PermissionExchange contract

* Update exchange startup config
  • Loading branch information
mzxyz authored Sep 28, 2023
1 parent 61932c3 commit 23f851a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
8 changes: 4 additions & 4 deletions publish/kepler.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@
"lastUpdate": "Wed, 16 Aug 2023 05:33:10 GMT"
},
"PermissionedExchange": {
"innerAddress": "0xc79E996f456918dE2FD3eB8d526D93E25707cb6F",
"innerAddress": "0x225Ff1b98725D24E449ab9B2cBF247FBb7d7e7EC",
"address": "0x063482d40B31f78d4aDA6D0CDCBaE73F07Ea4865",
"bytecodeHash": "f16cf49a5ccddb4491f5e8487bcbf5021d7eeab1359f8c189b86cd3804d99962",
"lastUpdate": "Wed, 16 Aug 2023 05:37:33 GMT"
"bytecodeHash": "bd692650e77b19f4d9318c12c2351b30c8240ac56a051cbca659992e4775d6a2",
"lastUpdate": "Wed, 27 Sep 2023 12:28:51 GMT"
},
"ConsumerHost": {
"innerAddress": "0x61ABE767503333d72f1E59ae8e503B87B45b9b6D",
Expand All @@ -149,4 +149,4 @@
"bytecodeHash": "d95aa2638edb0b1ce643f883a60435b44390ac9e78035b6c0579ba1b50b54a33",
"lastUpdate": "Wed, 13 Sep 2023 01:00:41 GMT"
}
}
}
6 changes: 3 additions & 3 deletions publish/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
"lastUpdate": "Thu, 17 Aug 2023 21:20:27 GMT"
},
"PermissionedExchange": {
"innerAddress": "0xADCB823C6CbCBCFAEa1f9041982C8720B91e711C",
"innerAddress": "0xDd440C0E3D0Af8b4731bD10288c23f94B1c1d116",
"address": "0x2f6CcFEB92Df62c928c40f9535958426CE37C06D",
"bytecodeHash": "f16cf49a5ccddb4491f5e8487bcbf5021d7eeab1359f8c189b86cd3804d99962",
"lastUpdate": "Thu, 17 Aug 2023 21:20:54 GMT"
"bytecodeHash": "bd692650e77b19f4d9318c12c2351b30c8240ac56a051cbca659992e4775d6a2",
"lastUpdate": "Wed, 27 Sep 2023 12:25:22 GMT"
},
"ConsumerHost": {
"innerAddress": "0xFb4831C3B532291062B026Cd943B01fc56CA0e92",
Expand Down
4 changes: 2 additions & 2 deletions scripts/config/startup.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
{"period": 7200, "dailyReqCap": 100, "rateLimit": 300, "token": "0xed3bb617dbC128095f8b0A00B9498C2Ef5c3D04a"}
],
"exchange": {
"usdcAddress": "0xE097d6B3100777DC31B34dC2c58fB524C2e76921",
"usdcAddress": "0x7E65A71046170A5b1AaB5C5cC64242EDF95CaBEA",
"amountGive": "1000000",
"amountGet": "5000000000000000000",
"expireDate": 1683147171,
"expireDate": 1703681276,
"tokenGiveBalance": "50000000"
},
"QRCreator": ["0x293a6d85DD0d7d290A719Fdeef43FaD10240bA77"],
Expand Down
11 changes: 8 additions & 3 deletions scripts/deployContracts.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import moduleAlias from 'module-alias';
moduleAlias.addAlias('./artifacts', '../artifacts');
moduleAlias.addAlias('./publish', '../publish');

import { Wallet } from '@ethersproject/wallet';
import { BaseContract, Contract, Overrides } from 'ethers';
import { readFileSync, writeFileSync } from 'fs';
import Pino from 'pino';
import sha256 from 'sha256';

import CONTRACTS from '../src/contracts';
import { ContractDeployment, ContractName } from '../src/types';
import { TextColor, colorText, getLogger } from './logger';

import { SubqueryNetwork } from '@subql/contract-sdk';

import {
AdminUpgradeabilityProxy__factory,
Airdropper,
Expand Down Expand Up @@ -432,7 +438,7 @@ export async function upgradeContracts(configs: {
wallet = configs.wallet;

const logger = getLogger('Upgrade Contract');
logger.info(`Upgrade contrqact with wallet ${wallet.address}`);
logger.info(`Upgrade contract with wallet ${wallet.address}`);

const proxyAdmin = ProxyAdmin__factory.connect(deployment.ProxyAdmin.address, wallet);

Expand All @@ -454,9 +460,8 @@ export async function upgradeContracts(configs: {
logger.info(`Contract Changed: ${changed.join(',')}`);
if (checkOnly) return deployment;

const changedContracts = ['PlanManager', 'ServiceAgreementRegistry']

for (const contractName of changedContracts) {
for (const contractName of changed) {
const [_, factory] = UPGRADEBAL_CONTRACTS[contractName];
if (!deployment[contractName]) {
console.warn(`contract ${contractName} not deployed`);
Expand Down
3 changes: 0 additions & 3 deletions src/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import { ContractDeployment, SubqueryNetwork } from './types';

// import moduleAlias from 'module-alias';
// moduleAlias.addAlias('./publish', '../publish');

import keplerDeployment from './publish/kepler.json';
import mainnetDeployment from './publish/mainnet.json';
import testnetDeployment from './publish/testnet.json';
Expand Down

0 comments on commit 23f851a

Please sign in to comment.