Socket
Socket
Sign inDemoInstall

@dxdao/aqua

Package Overview
Dependencies
Maintainers
5
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dxdao/aqua - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

62

dist/Aqua.js

@@ -13,4 +13,3 @@ "use strict";

exports.Aqua = void 0;
const contracts_1 = require("./contracts");
const encoders_1 = require("./encoders");
const aqua_sc_1 = require("@dxdao/aqua-sc");
const errors_1 = require("./errors");

@@ -20,7 +19,8 @@ const Subgraph_1 = require("./Subgraph");

constructor({ factory, saleLauncher, templateLauncher, subgraph }, signerOrProvider) {
this.factory = contracts_1.Contracts.AquaFactory.connect(factory, signerOrProvider);
this.saleLauncher = contracts_1.Contracts.SaleLauncher.connect(saleLauncher, signerOrProvider);
this.templateLauncher = contracts_1.Contracts.TemplateLauncher.connect(templateLauncher, signerOrProvider);
this.factory = aqua_sc_1.AquaFactory__factory.connect(factory, signerOrProvider);
this.saleLauncher = aqua_sc_1.SaleLauncher__factory.connect(saleLauncher, signerOrProvider);
this.templateLauncher = aqua_sc_1.TemplateLauncher__factory.connect(templateLauncher, signerOrProvider);
this.subgraph = new Subgraph_1.Subgraph(subgraph);
this.provider = signerOrProvider;
this.confirmationNumber = 3;
}

@@ -37,3 +37,3 @@ contracts() {

const addTemplateTx = yield this.saleLauncher.addTemplate(saleAddress);
const addTemplateTxReceipt = addTemplateTx.wait(1);
const addTemplateTxReceipt = addTemplateTx.wait(this.confirmationNumber);
return addTemplateTxReceipt;

@@ -45,3 +45,3 @@ });

const addTemplateTx = yield this.templateLauncher.addTemplate(saleTemplateAddress);
const addTemplateTxReceipt = yield addTemplateTx.wait(1);
const addTemplateTxReceipt = yield addTemplateTx.wait(this.confirmationNumber);
return addTemplateTxReceipt;

@@ -52,14 +52,15 @@ });

return __awaiter(this, void 0, void 0, function* () {
const templateName = `FixedPriceSaleTemplate`;
const transactions = [];
const saleTemplates = yield this.subgraph.getSaleTemplates();
const fixedPriceSaleTemplate = saleTemplates.find(({ name }) => name == 'FixedPriceSaleTemplate');
if (!fixedPriceSaleTemplate) {
throw new errors_1.SaleTemplateNotRegistered('Mesa: FixedPriceSaleTemplate is not registered');
const template = saleTemplates.find(({ name }) => name == templateName);
if (!template) {
throw new errors_1.SaleTemplateNotRegistered(templateName);
}
const saleOptionsInitDataBytes = encoders_1.encodeInitDataFixedPriceSale(Object.assign(Object.assign({}, saleOptions), { saleLauncher: this.saleLauncher.address, saleTemplateId: fixedPriceSaleTemplate.id }));
const launchTemplateTx = yield this.factory.launchTemplate(fixedPriceSaleTemplate.id, saleOptionsInitDataBytes, metaData);
const saleOptionsInitDataBytes = aqua_sc_1.encodeInitDataFixedPriceSale(Object.assign(Object.assign({}, saleOptions), { saleLauncher: this.saleLauncher.address, saleTemplateId: template.id }));
const launchTemplateTx = yield this.factory.launchTemplate(template.id, saleOptionsInitDataBytes, metaData);
transactions.push(launchTemplateTx);
const launchTemplateTxRecipt = yield launchTemplateTx.wait(2);
const launchTemplateTxRecipt = yield launchTemplateTx.wait(this.confirmationNumber);
const templateAddress = this.getLaunchedTemplateAddress(launchTemplateTxRecipt);
const saleTemplate = contracts_1.Contracts.FixedPriceSaleTemplate.connect(templateAddress, this.provider);
const saleTemplate = aqua_sc_1.FixedPriceSaleTemplate__factory.connect(templateAddress, this.provider);
const createSaleTx = yield saleTemplate.createSale({

@@ -69,6 +70,6 @@ value: yield this.factory.saleFee(),

transactions.push(createSaleTx);
const createSaleTxReceipt = yield createSaleTx.wait(3);
const createSaleTxReceipt = yield createSaleTx.wait(this.confirmationNumber);
const newSaleAddress = `0x${createSaleTxReceipt.logs[0].topics[1].substring(26)}`;
return {
fixedPriceSale: contracts_1.Contracts.FixedPriceSale.connect(newSaleAddress, this.provider),
sale: aqua_sc_1.FixedPriceSale__factory.connect(newSaleAddress, this.provider),
transactions,

@@ -78,2 +79,29 @@ };

}
createFairSale(saleOptions, metaData) {
return __awaiter(this, void 0, void 0, function* () {
const templateName = `FairSaleTemplate`;
const transactions = [];
const saleTemplates = yield this.subgraph.getSaleTemplates();
const template = saleTemplates.find(({ name }) => name == templateName);
if (!template) {
throw new errors_1.SaleTemplateNotRegistered(templateName);
}
const saleOptionsInitDataBytes = aqua_sc_1.encodeInitDataFairSale(Object.assign(Object.assign({}, saleOptions), { saleLauncher: this.saleLauncher.address, saleTemplateId: template.id }));
const launchTemplateTx = yield this.factory.launchTemplate(template.id, saleOptionsInitDataBytes, metaData);
transactions.push(launchTemplateTx);
const launchTemplateTxRecipt = yield launchTemplateTx.wait(this.confirmationNumber);
const templateAddress = this.getLaunchedTemplateAddress(launchTemplateTxRecipt);
const saleTemplate = aqua_sc_1.FixedPriceSaleTemplate__factory.connect(templateAddress, this.provider);
const createSaleTx = yield saleTemplate.createSale({
value: yield this.factory.saleFee(),
});
transactions.push(createSaleTx);
const createSaleTxReceipt = yield createSaleTx.wait(this.confirmationNumber);
const newSaleAddress = `0x${createSaleTxReceipt.logs[0].topics[1].substring(26)}`;
return {
sale: aqua_sc_1.FairSale__factory.connect(newSaleAddress, this.provider),
transactions,
};
});
}
getLaunchedTemplateAddress(transctionReceipt) {

@@ -85,3 +113,3 @@ if (!transctionReceipt.events) {

if (!eventTemplateLaunched || !eventTemplateLaunched.args) {
throw new errors_1.AquaError('Transction did not emit any event TemplateLaunched');
throw new errors_1.AquaError('Transction did not emit TemplateLaunched event');
}

@@ -88,0 +116,0 @@ return eventTemplateLaunched.args.template;

@@ -5,5 +5,5 @@ "use strict";

class AquaError extends Error {
constructor() {
super(...arguments);
this.name = 'AquaError';
constructor(message) {
super(message);
super.name = 'AquaError';
}

@@ -13,4 +13,7 @@ }

class SaleTemplateNotRegistered extends AquaError {
constructor(template) {
super(`Template ${template} is not registered`);
}
}
exports.SaleTemplateNotRegistered = SaleTemplateNotRegistered;
//# sourceMappingURL=errors.js.map

@@ -9,36 +9,26 @@ "use strict";

}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RINKEBY_CONFIG = exports.XDAI_CONFIG = exports.encoders = void 0;
exports.RINKEBY_CONFIG = exports.XDAI_CONFIG = void 0;
const aqua_sc_1 = require("@dxdao/aqua-sc");
__exportStar(require("./Aqua"), exports);
__exportStar(require("./Subgraph"), exports);
__exportStar(require("./types"), exports);
exports.encoders = __importStar(require("./encoders"));
__exportStar(require("./contracts"), exports);
__exportStar(require("@dxdao/aqua-sc"), exports);
const xdaiAddresses = aqua_sc_1.getContractAddressesForChainOrThrow(aqua_sc_1.ChainId.xdai);
exports.XDAI_CONFIG = {
factory: '0x6897427e8d129d040F066a3Dcb106da91e84ab47',
saleLauncher: '0xfa4Fbd5DC4a0C3aE54aA3a1fE52099d7d6F94227',
templateLauncher: '0x1c1006D122A7f09A047f42D16464A3e7fBdB24C2',
factory: xdaiAddresses.aquaFactory,
saleLauncher: xdaiAddresses.saleLauncher,
templateLauncher: xdaiAddresses.templateLauncher,
subgraph: 'https://api.thegraph.com/subgraphs/name/adamazad/aqua-xdai-next',
};
const rinkebyAddresses = aqua_sc_1.getContractAddressesForChainOrThrow(aqua_sc_1.ChainId.rinkeby);
exports.RINKEBY_CONFIG = {
factory: '0x6f90A6b92b69A775d0a2231011b3704d876b51a8',
saleLauncher: '0x6f90A6b92b69A775d0a2231011b3704d876b51a8',
templateLauncher: '0xA731dEc18bD791D817bd67E9944793D5BF76f5C0',
subgraph: 'https://api.thegraph.com/subgraphs/name/adamazad/mesa',
factory: rinkebyAddresses.aquaFactory,
saleLauncher: rinkebyAddresses.saleLauncher,
templateLauncher: rinkebyAddresses.templateLauncher,
subgraph: 'https://api.thegraph.com/subgraphs/name/mprasanjith/aqua-rinkeby-next',
};
//# sourceMappingURL=index.js.map

@@ -0,0 +0,0 @@ "use strict";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=sales.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=subgraph.js.map
{
"name": "@dxdao/aqua",
"version": "0.1.3",
"version": "0.1.4",
"private": false,
"description": "MesaJS gives developers access to the entire Mesa ecosystem a single package",
"description": "AquaJS gives developers access to the entire Aqua ecosystem a single package",
"main": "dist/index.js",
"dependencies": {
"@dxdao/aqua-sc": "^0.1.2-0",
"@ethersproject/providers": "^5.1.2",

@@ -13,3 +14,2 @@ "axios": "^0.21.1",

"devDependencies": {
"@typechain/ethers-v5": "^6.0.5",
"@types/graphql": "^14.5.0",

@@ -19,13 +19,11 @@ "apollo": "^2.32.8",

"nodemon": "^2.0.7",
"typechain": "^4.0.3",
"typescript": "^4.2.4"
},
"scripts": {
"typechain": "typechain --target ethers-v5 --outDir src/contracts abis/*.json",
"build-abis": "build-abis.sh",
"build": "tsc"
"clear": "rm -rf dist && rm -rf types",
"build": "yarn clear && tsc"
},
"repository": {
"type": "git",
"url": "git+https://github.com/cryptonative-ch/mesa-js.git"
"url": "git+https://github.com/cryptonative-ch/aqua-js.git"
},

@@ -49,6 +47,6 @@ "files": [

"bugs": {
"url": "https://github.com/cryptonative-ch/mesa-js/issues"
"url": "https://github.com/cryptonative-ch/aqua-js/issues"
},
"homepage": "https://github.com/cryptonative-ch/mesa-js#readme",
"homepage": "https://github.com/cryptonative-ch/aqua-js#readme",
"types": "types/index.d.ts"
}
# Overview
There are 3 main components:
1. Mesa class. Creates a instance that allows developer to create sales, add sale modules and add templates. Exposes the three main contracts: MesaFactory, SaleLauncher and TemplateLauncher
1. Aqua class. Creates a instance that allows developer to create sales, add sale modules and add templates. Exposes the three main contracts: AquaFactory, SaleLauncher and TemplateLauncher
2. Subgraph class. Accepts the graphqhl endpoint and offers methods to read from the Subgraph.
3. Sales module. Exports helper functions to interact with Mesa Sales
3. Sales module. Exports helper functions to interact with Aqua Sales

@@ -8,0 +8,0 @@ Others:

import { ContractReceipt, ContractTransaction } from 'ethers';
import { Provider } from '@ethersproject/abstract-provider';
import { Signer } from '@ethersproject/abstract-signer';
import { AquaFactory, FixedPriceSale, SaleLauncher, TemplateLauncher } from './contracts';
import { AquaFactory, FairSale, FixedPriceSale, SaleLauncher, TemplateLauncher } from '@dxdao/aqua-sc';
import { Subgraph } from './Subgraph';
import { FixedPriceSaleOptions, AquaConfigMap } from './types';
interface AquaContracts {
factory: AquaFactory;
saleLauncher: SaleLauncher;
templateLauncher: TemplateLauncher;
import { FixedPriceSaleOptions, FairPriceSaleOptions, AquaConfigMap, AquaContracts } from './types';
interface CreateSaleReturn<T> {
sale: T;
transactions: ContractTransaction[];
}

@@ -18,2 +17,3 @@ export declare class Aqua {

readonly provider: Signer | Provider;
confirmationNumber: number;
constructor({ factory, saleLauncher, templateLauncher, subgraph }: AquaConfigMap, signerOrProvider: Signer | Provider);

@@ -23,8 +23,6 @@ contracts(): AquaContracts;

addSaleTemplate(saleTemplateAddress: string): Promise<ContractReceipt>;
createFixedPriceSale(saleOptions: FixedPriceSaleOptions, metaData: string): Promise<{
fixedPriceSale: FixedPriceSale;
transactions: ContractTransaction[];
}>;
createFixedPriceSale(saleOptions: FixedPriceSaleOptions, metaData: string): Promise<CreateSaleReturn<FixedPriceSale>>;
createFairSale(saleOptions: FairPriceSaleOptions, metaData: string): Promise<CreateSaleReturn<FairSale>>;
getLaunchedTemplateAddress(transctionReceipt: ContractReceipt): string;
}
export {};
export declare class AquaError extends Error {
name: string;
constructor(message: string);
}
export declare class SaleTemplateNotRegistered extends AquaError {
constructor(template: string);
}

@@ -5,5 +5,4 @@ import { AquaConfigMap } from './types';

export * from './types';
export * as encoders from './encoders';
export * from './contracts';
export * from '@dxdao/aqua-sc';
export declare const XDAI_CONFIG: AquaConfigMap;
export declare const RINKEBY_CONFIG: AquaConfigMap;

@@ -0,0 +0,0 @@ import { BigNumber } from '@ethersproject/bignumber';

import type { Provider } from '@ethersproject/providers';
import type { Signer } from 'ethers';
import type { AquaFactory, SaleLauncher, TemplateLauncher } from '../contracts';
import type { AquaFactory, SaleLauncher, TemplateLauncher } from '@dxdao/aqua-sc';
import type { Subgraph } from '../Subgraph';
export type { InitDataFairSaleOptions, InitDataFixedPriceSaleOptions } from './encoders';
export type { FixedPriceSaleOptions } from './sales';
export type { InitDataFairSaleOptions, InitDataFixedPriceSaleOptions } from '@dxdao/aqua-sc';
export type { FixedPriceSaleOptions, FairPriceSaleOptions } from './sales';
export type { BooleanMap, DocumentTimestampFields, FixedPriceSaleBase, FixedPriceSalePopulated, FixedPriceSalePurchase, MesaFactory, SaleTemplate, Token, } from './subgraph';

@@ -15,3 +15,3 @@ export interface CreateInstanceOptions {

}
export interface MesaContracts {
export interface AquaContracts {
factory: AquaFactory;

@@ -22,3 +22,3 @@ saleLauncher: SaleLauncher;

export interface AquaInstance<P = Provider | Signer> {
contracts: MesaContracts;
contracts: AquaContracts;
subgraph: Subgraph;

@@ -28,7 +28,7 @@ provider: P;

export interface AddSaleOptions {
mesa: AquaInstance;
aqua: AquaInstance;
sale: string;
}
export interface AddTemplateOptions {
mesa: AquaInstance;
aqua: AquaInstance;
template: string;

@@ -35,0 +35,0 @@ }

@@ -1,2 +0,3 @@

import { InitDataFixedPriceSaleOptions } from './encoders';
import { InitDataFixedPriceSaleOptions, InitDataFairSaleOptions } from '@dxdao/aqua-sc';
export declare type FixedPriceSaleOptions = Pick<InitDataFixedPriceSaleOptions, Exclude<keyof InitDataFixedPriceSaleOptions, 'saleLauncher' | 'saleTemplateId'>>;
export declare type FairPriceSaleOptions = Pick<InitDataFairSaleOptions, Exclude<keyof InitDataFairSaleOptions, 'saleLauncher' | 'saleTemplateId'>>;

@@ -0,0 +0,0 @@ import { BigNumber } from '@ethersproject/bignumber';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc