Skip to content

Commit

Permalink
Add proxy deployer
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Dec 13, 2023
1 parent 0b6a8d9 commit 57ac4e3
Show file tree
Hide file tree
Showing 20 changed files with 586 additions and 6 deletions.
51 changes: 47 additions & 4 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
Expand Up @@ -39,7 +39,7 @@
"@aws-sdk/lib-storage": "^3.438.0",
"@elastic/elasticsearch": "7.12.0",
"@golevelup/nestjs-rabbitmq": "4.0.0",
"@multiversx/sdk-core": "12.6.1",
"@multiversx/sdk-core": "12.14.0",
"@multiversx/sdk-native-auth-server": "1.0.7",
"@multiversx/sdk-nestjs-cache": "2.0.0-beta.2",
"@multiversx/sdk-nestjs-common": "2.0.0-beta.2",
Expand Down
10 changes: 9 additions & 1 deletion schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,13 @@ input DeployMinterArgs {
royaltiesClaimAddress: String!
}

input DeployMinterArgsP {
maxNftsPerTransaction: Int!
mintClaimAddress: String!
ownerAddress: String!
royaltiesClaimAddress: String!
}

type ExploreCollectionsStats {
activeLast30DaysCount: Int!
allCollectionsCount: Int!
Expand Down Expand Up @@ -977,6 +984,7 @@ type Mutation {
deployMinter(input: DeployMinterArgs!): TransactionNode!
disableMarketplace(input: UpdateMarketplaceStateArgs!): Boolean!
enableMarketplace(input: UpdateMarketplaceStateArgs!): Boolean!
deployMinterP(input: DeployMinterArgsP!): TransactionNode!
endAuction(auctionId: Int!): TransactionNode!
flagCollection(input: FlagCollectionInput!): Boolean!
flagNft(input: FlagNftInput!): Boolean!
Expand Down Expand Up @@ -1553,4 +1561,4 @@ input WhitelistMarketplaceArgs {
input WhitelistMinterArgs {
address: String!
adminAddress: String!
}
}
150 changes: 150 additions & 0 deletions src/abis/proxy-deployer.abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"buildInfo": {
"rustc": {
"version": "1.71.0-nightly",
"commitHash": "7f94b314cead7059a71a265a8b64905ef2511796",
"commitDate": "2023-04-23",
"channel": "Nightly",
"short": "rustc 1.71.0-nightly (7f94b314c 2023-04-23)"
},
"contractCrate": {
"name": "proxy-deployer",
"version": "0.0.0"
},
"framework": {
"name": "multiversx-sc",
"version": "0.43.4"
}
},
"name": "ProxyDeployer",
"constructor": {
"inputs": [],
"outputs": []
},
"endpoints": [
{
"name": "upgrade",
"mutability": "mutable",
"inputs": [],
"outputs": []
},
{
"name": "contractDeploy",
"mutability": "mutable",
"inputs": [
{
"name": "template_address_id",
"type": "u64"
},
{
"name": "args",
"type": "variadic<bytes>",
"multi_arg": true
}
],
"outputs": [
{
"type": "Address"
}
]
},
{
"name": "contractUpgrade",
"mutability": "mutable",
"inputs": [
{
"name": "contract_address",
"type": "Address"
},
{
"name": "template_address_id",
"type": "u64"
},
{
"name": "args",
"type": "variadic<bytes>",
"multi_arg": true
}
],
"outputs": []
},
{
"name": "callContractEndpoint",
"mutability": "mutable",
"inputs": [
{
"name": "contract_address",
"type": "Address"
},
{
"name": "function_name",
"type": "bytes"
},
{
"name": "args",
"type": "variadic<bytes>",
"multi_arg": true
}
],
"outputs": []
},
{
"name": "addContractTemplate",
"onlyOwner": true,
"mutability": "mutable",
"inputs": [
{
"name": "template_address",
"type": "Address"
}
],
"outputs": [
{
"type": "u64"
}
]
},
{
"name": "removeContractTemplate",
"onlyOwner": true,
"mutability": "mutable",
"inputs": [
{
"name": "address_id",
"type": "u64"
}
],
"outputs": []
},
{
"name": "getAllDeployers",
"mutability": "readonly",
"inputs": [],
"outputs": [
{
"type": "variadic<Address>",
"multi_result": true
}
]
},
{
"name": "getDeployerContractAddresses",
"mutability": "readonly",
"inputs": [
{
"name": "deployer_address",
"type": "Address"
}
],
"outputs": [
{
"type": "variadic<Address>",
"multi_result": true
}
]
}
],
"events": [],
"hasCallback": false,
"types": {}
}
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import '@multiversx/sdk-nestjs-common/lib/utils/extensions/number.extensions';
import { TimescaleDbModule } from './common/persistence/timescaledb/timescaledb.module';
import { MintersModuleGraph } from './modules/minters/minters.module';
import { PersistenceModule } from './common/persistence/persistence.module';
import { ProxyDeployerModuleGraph } from './modules/proxy-deployer/proxy-deployer.module';

@Module({
imports: [
Expand Down Expand Up @@ -99,6 +100,7 @@ import { PersistenceModule } from './common/persistence/persistence.module';
ExploreStatsModuleGraph,
TimescaleDbModule,
MintersModuleGraph,
ProxyDeployerModuleGraph,
],
})
export class AppModule {}
2 changes: 2 additions & 0 deletions src/modules/auctions/contractLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ export class ContractLoader {
try {
const jsonContent: string = await fs.promises.readFile(this.abiPath, { encoding: 'utf8' });
const json = JSON.parse(jsonContent);
console.log({ json: JSON.stringify(json) });

const abiRegistry = AbiRegistry.create(json);
console.log(abiRegistry.getEndpoint('contractDeploy'));

return abiRegistry;
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/modules/auctions/marketplaceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class MarketplaceUtils {
public static readonly xoxnoMarketplaceAbiPath: string = './src/abis/xoxno-nft-marketplace.abi.json';

public static readonly deployerMintersAbiPath: string = './src/abis/nft-minter-deployer.abi.json';
public static readonly proxyDeployerMintersAbiPath: string = './src/abis/proxy-deployer.abi.json';
static isExternalMarketplace(type: MarketplaceTypeEnum) {
return type === MarketplaceTypeEnum.External;
}
Expand Down
14 changes: 14 additions & 0 deletions src/modules/proxy-deployer/models/AddMinterArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Field, InputType, Int } from '@nestjs/graphql';
import { Matches } from 'class-validator';
import { ADDRESS_ERROR, ADDRESS_RGX } from 'src/utils/constants';

@InputType()
export class WhitelistMinterArgs {
@Matches(RegExp(ADDRESS_RGX), { message: ADDRESS_ERROR })
@Field()
address: string;

@Matches(RegExp(ADDRESS_RGX), { message: ADDRESS_ERROR })
@Field()
adminAddress: string;
}
28 changes: 28 additions & 0 deletions src/modules/proxy-deployer/models/DeployMinterArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Field, InputType, Int } from '@nestjs/graphql';
import { Matches } from 'class-validator';
import { ADDRESS_ERROR, ADDRESS_RGX } from 'src/utils/constants';

@InputType()
export class DeployMinterArgsP {
@Matches(RegExp(ADDRESS_RGX), { message: ADDRESS_ERROR })
@Field()
royaltiesClaimAddress: string;

@Matches(RegExp(ADDRESS_RGX), { message: ADDRESS_ERROR })
@Field()
ownerAddress: string;

@Matches(RegExp(ADDRESS_RGX), { message: ADDRESS_ERROR })
@Field()
mintClaimAddress: string;

@Field(() => Int)
maxNftsPerTransaction: number;
}

@InputType()
export class UpgradeMinterArgs {
@Matches(RegExp(ADDRESS_RGX), { message: ADDRESS_ERROR })
@Field()
minterAddress: string;
}
24 changes: 24 additions & 0 deletions src/modules/proxy-deployer/models/Minter.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Field, ID, ObjectType } from '@nestjs/graphql';
import { MinterEntity } from 'src/db/minters';

@ObjectType()
export class Minter {
@Field(() => ID)
address!: string;

@Field(() => ID)
adminAddress!: string;

constructor(init?: Partial<Minter>) {
Object.assign(this, init);
}

static fromEntity(minter: MinterEntity) {
return minter
? new Minter({
address: minter.address,
adminAddress: minter.adminAddress,
})
: null;
}
}
18 changes: 18 additions & 0 deletions src/modules/proxy-deployer/models/MinterFilters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Field, InputType, Int } from '@nestjs/graphql';
import { Matches } from 'class-validator';
import { ADDRESS_ERROR, ADDRESS_RGX } from 'src/utils/constants';

@InputType()
export class MinterFilters {
@Matches(RegExp(ADDRESS_RGX), { message: ADDRESS_ERROR })
@Field()
minterAddress: string;

@Matches(RegExp(ADDRESS_RGX), { message: ADDRESS_ERROR })
@Field()
minterAdminAddress: string;

constructor(init?: Partial<MinterFilters>) {
Object.assign(this, init);
}
}
6 changes: 6 additions & 0 deletions src/modules/proxy-deployer/models/MintersResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ObjectType } from '@nestjs/graphql';
import relayTypes from 'src/modules/common/Relay.types';
import { Minter } from './Minter.dto';

@ObjectType()
export class MintersResponse extends relayTypes<Minter>(Minter) {}
2 changes: 2 additions & 0 deletions src/modules/proxy-deployer/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './Minter.dto';
export * from './AddMinterArgs';
Loading

0 comments on commit 57ac4e3

Please sign in to comment.