@verax-attestation-registry/verax-sdk
Version:
Verax Attestation Registry SDK to interact with the subgraph and the contracts
175 lines • 8.4 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VeraxSdk = void 0;
const chains_1 = require("viem/chains");
const AttestationDataMapper_1 = __importDefault(require("./dataMapper/AttestationDataMapper"));
const SchemaDataMapper_1 = __importDefault(require("./dataMapper/SchemaDataMapper"));
const ModuleDataMapper_1 = __importDefault(require("./dataMapper/ModuleDataMapper"));
const PortalDataMapper_1 = __importDefault(require("./dataMapper/PortalDataMapper"));
const viem_1 = require("viem");
const UtilsDataMapper_1 = __importDefault(require("./dataMapper/UtilsDataMapper"));
const accounts_1 = require("viem/accounts");
const constants_1 = require("./utils/constants");
__exportStar(require("./types"), exports);
__exportStar(require("./utils/constants"), exports);
class VeraxSdk {
constructor(conf, publicAddress, privateKey) {
let transport;
if (conf.rpcUrl) {
transport = (0, viem_1.http)(conf.rpcUrl);
}
else if (conf.mode === constants_1.SDKMode.FRONTEND && typeof window.ethereum !== "undefined") {
transport = (0, viem_1.custom)(window.ethereum);
}
else {
transport = (0, viem_1.http)();
}
this.web3Client = (0, viem_1.createPublicClient)({
chain: conf.chain,
transport,
});
if (conf.mode === constants_1.SDKMode.BACKEND) {
this.walletClient = (0, viem_1.createWalletClient)({
chain: conf.chain,
account: privateKey ? (0, accounts_1.privateKeyToAccount)(privateKey) : undefined,
transport,
});
}
else if (typeof window.ethereum !== "undefined") {
this.walletClient = (0, viem_1.createWalletClient)({
chain: conf.chain,
account: publicAddress,
transport: (0, viem_1.custom)(window.ethereum),
});
}
this.attestation = new AttestationDataMapper_1.default(conf, this.web3Client, this, this.walletClient);
this.schema = new SchemaDataMapper_1.default(conf, this.web3Client, this, this.walletClient);
this.module = new ModuleDataMapper_1.default(conf, this.web3Client, this, this.walletClient);
this.portal = new PortalDataMapper_1.default(conf, this.web3Client, this, this.walletClient);
this.utils = new UtilsDataMapper_1.default(conf, this.web3Client, this, this.walletClient);
}
}
exports.VeraxSdk = VeraxSdk;
VeraxSdk.DEFAULT_LINEA_MAINNET = {
chain: chains_1.linea,
mode: constants_1.SDKMode.BACKEND,
subgraphUrl: "https://api.studio.thegraph.com/query/67521/verax-v2-linea/v0.0.1",
// Backup URL: subgraphUrl: "https://api.goldsky.com/api/public/project_clxx488osyuf501vygg71f86w/subgraphs/verax-v2-linea/0.0.1/gn",
portalRegistryAddress: "0xd5d61e4ECDf6d46A63BfdC262af92544DFc19083",
moduleRegistryAddress: "0xf851513A732996F22542226341748f3C9978438f",
schemaRegistryAddress: "0x0f95dCec4c7a93F2637eb13b655F2223ea036B59",
attestationRegistryAddress: "0x3de3893aa4Cdea029e84e75223a152FD08315138",
};
VeraxSdk.DEFAULT_LINEA_MAINNET_FRONTEND = {
...VeraxSdk.DEFAULT_LINEA_MAINNET,
mode: constants_1.SDKMode.FRONTEND,
};
VeraxSdk.DEFAULT_LINEA_SEPOLIA = {
chain: chains_1.lineaSepolia,
mode: constants_1.SDKMode.BACKEND,
subgraphUrl: "https://api.studio.thegraph.com/query/67521/verax-v2-linea-sepolia/v0.0.2",
portalRegistryAddress: "0xF35fe79104e157703dbCC3Baa72a81A99591744D",
moduleRegistryAddress: "0x3C443B9f0c8ed3A3270De7A4815487BA3223C2Fa",
schemaRegistryAddress: "0x90b8542d7288a83EC887229A7C727989C3b56209",
attestationRegistryAddress: "0xDaf3C3632327343f7df0Baad2dc9144fa4e1001F",
};
VeraxSdk.DEFAULT_LINEA_SEPOLIA_FRONTEND = {
...VeraxSdk.DEFAULT_LINEA_SEPOLIA,
mode: constants_1.SDKMode.FRONTEND,
};
VeraxSdk.DEFAULT_ARBITRUM_SEPOLIA = {
chain: chains_1.arbitrumSepolia,
mode: constants_1.SDKMode.BACKEND,
subgraphUrl: "https://api.studio.thegraph.com/query/67521/verax-v2-arbitrum-sepolia/v0.0.2",
portalRegistryAddress: "0x1ceb52584B6C45C7049dc7fDC476bC138E4beaDE",
moduleRegistryAddress: "0xEC572277d4E87a64DcfA774ED219Dd4E69E4BDc6",
schemaRegistryAddress: "0x025531b655D9EE335B8E6cc4C118b313f26ACc8F",
attestationRegistryAddress: "0xee5e23492bf49C1F4CF0676b3bF49d78A6dD61c5",
};
VeraxSdk.DEFAULT_ARBITRUM_SEPOLIA_FRONTEND = {
...VeraxSdk.DEFAULT_ARBITRUM_SEPOLIA,
mode: constants_1.SDKMode.FRONTEND,
};
VeraxSdk.DEFAULT_ARBITRUM = {
chain: chains_1.arbitrum,
mode: constants_1.SDKMode.BACKEND,
subgraphUrl: "https://api.studio.thegraph.com/query/67521/verax-v2-arbitrum/v0.0.2",
portalRegistryAddress: "0x4042D0A54f997EE3a1b0F51e4813654199BFd8bD",
moduleRegistryAddress: "0x3acF4daAB6cbc01546Dd4a96c9665B398d48A4ba",
schemaRegistryAddress: "0xE96072F46EA0e42e538762dDc0aFa4ED8AE6Ec27",
attestationRegistryAddress: "0x335E9719e8eFE2a19A92E07BC4836160fC31cd7C",
};
VeraxSdk.DEFAULT_ARBITRUM_FRONTEND = {
...VeraxSdk.DEFAULT_ARBITRUM,
mode: constants_1.SDKMode.FRONTEND,
};
VeraxSdk.DEFAULT_BASE_SEPOLIA = {
chain: chains_1.baseSepolia,
mode: constants_1.SDKMode.BACKEND,
subgraphUrl: "https://api.studio.thegraph.com/query/67521/verax-v2-base-sepolia/v0.0.2",
portalRegistryAddress: "0x025531b655D9EE335B8E6cc4C118b313f26ACc8F",
moduleRegistryAddress: "0xEC572277d4E87a64DcfA774ED219Dd4E69E4BDc6",
schemaRegistryAddress: "0x66D2F3DCc970343b83a6263E20832184fa71CFe7",
attestationRegistryAddress: "0x374B686137eC0DB442a8d833451f8C12cD4B5De4",
};
VeraxSdk.DEFAULT_BASE_SEPOLIA_FRONTEND = {
...VeraxSdk.DEFAULT_BASE_SEPOLIA,
mode: constants_1.SDKMode.FRONTEND,
};
VeraxSdk.DEFAULT_BASE = {
chain: chains_1.base,
mode: constants_1.SDKMode.BACKEND,
subgraphUrl: "https://api.studio.thegraph.com/query/67521/verax-v2-base/v0.0.1",
portalRegistryAddress: "0xcbf28432C25B400E645F0EaC05F8954e8EE7c0d6",
moduleRegistryAddress: "0xAd0C12db58098A6665CBEf48f60eB67d81d1F1ff",
schemaRegistryAddress: "0x8081dCd745f160c148Eb5be510F78628A0951c31",
attestationRegistryAddress: "0xA0080DBd35711faD39258E45d9A5D798852b05D4",
};
VeraxSdk.DEFAULT_BASE_FRONTEND = {
...VeraxSdk.DEFAULT_BASE,
mode: constants_1.SDKMode.FRONTEND,
};
VeraxSdk.DEFAULT_BSC_TESTNET = {
chain: chains_1.bscTestnet,
mode: constants_1.SDKMode.BACKEND,
subgraphUrl: "https://api.studio.thegraph.com/query/67521/verax-v2-bsc-testnet/v0.0.1",
portalRegistryAddress: "0xA4a7517F62216BD42e42a67dF09C25adc72A5897",
moduleRegistryAddress: "0x6c46c245918d4fcfC13F0a9e2e49d4E2739A353a",
schemaRegistryAddress: "0x51929da151eC2C5a5881C750E5b9941eACC46c1d",
attestationRegistryAddress: "0x5Cc4029f0dDae1FFE527385459D06d81DFD50EEe",
};
VeraxSdk.DEFAULT_BSC_TESTNET_FRONTEND = {
...VeraxSdk.DEFAULT_BSC_TESTNET,
mode: constants_1.SDKMode.FRONTEND,
};
VeraxSdk.DEFAULT_BSC = {
chain: chains_1.bsc,
mode: constants_1.SDKMode.BACKEND,
subgraphUrl: "https://api.studio.thegraph.com/query/67521/verax-v2-bsc/v0.0.1",
portalRegistryAddress: "0xb2553A7E443DFA7C9dEc01D327FdDff1A5eF59b0",
moduleRegistryAddress: "0xD70a06f7A0f197D55Fa841fcF668782b2B8266eB",
schemaRegistryAddress: "0x29205492435E1b06B20CeAeEC4AC41bcF595DFFd",
attestationRegistryAddress: "0x3D8A3a8FF21bD295dbBD5319C399e2C4FD27F261",
};
VeraxSdk.DEFAULT_BSC_FRONTEND = {
...VeraxSdk.DEFAULT_BSC,
mode: constants_1.SDKMode.FRONTEND,
};
//# sourceMappingURL=VeraxSdk.js.map