@spheron/protocol-sdk
Version:
Spheron Protocol SDK
2,694 lines (2,686 loc) • 1.18 MB
JavaScript
import { ethers } from 'ethers';
import { createPublicClient, http } from 'viem';
import { createSmartAccountClient, createBicoPaymasterClient, toNexusAccount } from '@biconomy/abstractjs';
// Testnet Contract Addresses
const AccessControlTestnet = '0x87D3440372293aCf9149552546F7141AAe05Be91';
const TokenRegistryTestnet$1 = '0x5227636cA07d665eeD8aE2df82A5412FD0CdA27A';
const ProviderRegistryTestnet = '0xB3D1e7166cC84de56740acb783f711E4cA26a756';
const ProviderAttributeRegistryTestnet = '0x904Cbe68afa39D793a41f44828E171a7BA9B9AA8';
const FizzRegistryTestnet = '0x9c0CFbb1EAF3023B4aB23337c8AEc8305763F42F';
const FizzAttributeRegistryTestnet = '0x91B695af9a2e8Ed896712eBEfe1E7278B572f84d';
const EscrowUserTestnet = '0x52d2Fb9B4Ad2A9Db97FB967e0d742Ce004345F48';
const EscrowProtocolTestnet$1 = '0x7d763d49481C1A3525591f33f9D94fAD220d5de7';
const OrderRequestTestnet$1 = '0xC15A83600fAF1eDBCF72e76584CD92111523cc1E';
const ComputeLeaseTestnet = '0x86F24B4C3BF800E295926B261532CEa44788DEc8';
const BidTestnet$1 = '0x87314967BaD22AAA7d4FB2bb149a6C57380535a3';
const ProviderResourceRegistryCPUTestnet = '0x67B8c2201Eef00d1a8193a2aF301312DD21a286B';
const ProviderResourceRegistryGPUTestnet = '0x2B73F279044347A3B6c9F122Ec6b479b6C2beAc9';
const FizzResourceRegistryCPUTestnet = '0x67B8c2201Eef00d1a8193a2aF301312DD21a286B'; // TODO: Needs to be updated as per new fizz CPU Registry contract
const FizzResourceRegistryGPUTestnet = '0x2B73F279044347A3B6c9F122Ec6b479b6C2beAc9'; // TODO: Needs to be updated as per new fizz GPU Registry contract
const ProviderRewardManagerTestnet = '0xe32279Bf9d47E20AEbb9ec04Ba5FB46536BA2aB5';
const FizzRewardManagerTestnet = '0xd653644FFD4ec06d173237FbA952C450A4973f5c';
const RewardTokenTestnet$1 = '0xB28aA1E5074AE0222cf764e2934182775Ee7AB42';
// Testnet Token addresses
const USDTTestnet = '0x96Ca5955F25648FB44C5D772BAdB4313000C66Fe';
const USDCTestnet = '0x816413630c39780677E1584D4a6DbAFd76b161F7';
const DAITestnet = '0xcF5F08686dBE94B88b93FB2E8E5482A7f432C892';
const WETHTestnet = '0xd74C08f8ffDF88C807367813Ad64a960618f4dcC';
const CSTTestnet = '0x8E5996A3963011Ca9dFa04E3CB773147F98C0e17';
const uSPONTestnet = '0xeD8F325cDc2BA7567395cb451A2ea8FAf40E23D2';
// Mainnet Contract Addresses
const TokenRegistryMainnet$1 = '0xDCD3eeE9f5Fb828C4EaE14B8Fe2382c0dDD6de01';
const AccessControlMainnet = '0x2F6dE416a7AEED365bE49DeB931D263EC742605C';
const ProviderRegistryMainnet$1 = '0x79c892AE9D910bBeb81705960BA01706Bb2Af02e';
const ProviderAttributeRegistryMainnet$1 = '0x4149Ff1496AA74F7A59989eb5332946fEed22705';
const FizzRegistryMainnet$1 = '0x1071F508b68E9cf8f338170295C952BDF509AE4D';
const FizzAttributeRegistryMainnet$1 = '0xB7AbA489Fe9F0eB930b8d298eD5FE669611cbf79';
const EscrowUserMainnet = '0x67Ad502B202Ac602C215B2Ba28689a71d03F9Ba4';
const EscrowProtocolMainnet$1 = '0x7381F084D31EF2F983c95572b7DD6Ee99eE03d8d';
const OrderRequestMainnet$1 = '0xC1A0AF3224465c2a5099C14c5A1A4f6680C30A86';
const ComputeLeaseMainnet$1 = '0x8A9f22D855bBE978C0D47De0963a3B15022E8ce0';
const BidMainnet$1 = '0x1582D6f9A7098B112dC76dd55a98d11d95f4702A';
const ProviderResourceRegistryCPUMainnet = '0x8Ac7BD17fA6E51E9719FaEfD8FD8Cc46ECAa93A9';
const ProviderResourceRegistryGPUMainnet = '0x360135261AB6CF9c9bBeF4c5d2B1fB9bb1671C8e';
const FizzResourceRegistryCPUMainnet = '0x285ce6294277FC29efD326c91dd3825fdEf76Ddb';
const FizzResourceRegistryGPUMainnet = '0xcfa353C1E6d3f625648f6E49D102026d63727c8A';
const ResourceRegistryFactoryMainnet$1 = '0xF302Af7f042A6D2e6A4c1fF67e4f69109d8f4Fa0';
const ProviderRewardManagerMainnet = '0x20f2159b1082529089752Bce0549a649B0f0032C';
const FizzRewardManagerMainnet = '0x8A01206Fd078Be34b28d689C92C1f2C05B3C641B';
const RewardTokenMainnet$1 = '0xA0c5ba7d9eccbE59000e8E67654CA5d867C6b401';
// Mainnet Token Addresses
const uSPONMainnet = '0xBf0fA0461331d815A103e59929E5a19A48C30f5e';
const contractAddresses = {
testnet: {
accessControlManager: AccessControlTestnet,
tokenRegistry: TokenRegistryTestnet$1,
providerRegistry: ProviderRegistryTestnet,
providerAttributeRegistry: ProviderAttributeRegistryTestnet,
fizzRegistry: FizzRegistryTestnet,
fizzAttributeRegistry: FizzAttributeRegistryTestnet,
escrow: EscrowUserTestnet,
escrowProtocol: EscrowProtocolTestnet$1,
orderRequest: OrderRequestTestnet$1,
computeLease: ComputeLeaseTestnet,
bid: BidTestnet$1,
providerResourceRegistryCPU: ProviderResourceRegistryCPUTestnet,
providerResourceRegistryGPU: ProviderResourceRegistryGPUTestnet,
fizzResourceRegistryCPU: FizzResourceRegistryCPUTestnet,
fizzResourceRegistryGPU: FizzResourceRegistryGPUTestnet,
providerRewardManager: ProviderRewardManagerTestnet,
fizzRewardManager: FizzRewardManagerTestnet,
rewardToken: RewardTokenTestnet$1,
USDT: USDTTestnet,
USDC: USDCTestnet,
DAI: DAITestnet,
WETH: WETHTestnet,
CST: CSTTestnet,
uSPON: uSPONTestnet,
},
mainnet: {
accessControlManager: AccessControlMainnet,
tokenRegistry: TokenRegistryMainnet$1,
providerRegistry: ProviderRegistryMainnet$1,
providerAttributeRegistry: ProviderAttributeRegistryMainnet$1,
fizzRegistry: FizzRegistryMainnet$1,
fizzAttributeRegistry: FizzAttributeRegistryMainnet$1,
escrow: EscrowUserMainnet,
escrowProtocol: EscrowProtocolMainnet$1,
orderRequest: OrderRequestMainnet$1,
computeLease: ComputeLeaseMainnet$1,
bid: BidMainnet$1,
providerResourceRegistryCPU: ProviderResourceRegistryCPUMainnet,
providerResourceRegistryGPU: ProviderResourceRegistryGPUMainnet,
fizzResourceRegistryCPU: FizzResourceRegistryCPUMainnet,
fizzResourceRegistryGPU: FizzResourceRegistryGPUMainnet,
resourceRegistryFactory: ResourceRegistryFactoryMainnet$1,
providerRewardManager: ProviderRewardManagerMainnet,
fizzRewardManager: FizzRewardManagerMainnet,
rewardToken: RewardTokenMainnet$1,
uSPON: uSPONMainnet,
},
};
// Testnet RPC URLs
const SPHERON_TESTNET_HTTP_URL = 'https://base-sepolia-rpc.publicnode.com';
const SPHERON_TESTNET_WSS_URL = 'wss://base-sepolia-rpc.publicnode.com';
const SPHERON_TESTNET_EXPLORER_URL = 'https://sepolia.basescan.org';
// Mainnet RPC URLs
const SPHERON_MAINNET_HTTP_URL = 'https://mainnet.base.org';
const SPHERON_MAINNET_WSS_URL = 'wss://base-rpc.publicnode.com';
const SPHERON_MAINNET_EXPLORER_URL = 'https://basescan.org/';
const publicRpcUrls = {
testnet: {
http: SPHERON_TESTNET_HTTP_URL,
websocket: SPHERON_TESTNET_WSS_URL,
explorer: SPHERON_TESTNET_EXPLORER_URL,
},
mainnet: {
http: SPHERON_MAINNET_HTTP_URL,
websocket: SPHERON_MAINNET_WSS_URL,
explorer: SPHERON_MAINNET_EXPLORER_URL,
},
};
const tokenMap = {
testnet: [
{
id: 1,
name: 'Tether USD Test Token',
symbol: 'USDT',
decimal: 6,
address: contractAddresses.testnet.USDT,
},
{
id: 2,
name: 'DAI Test Token',
symbol: 'DAI',
decimal: 18,
address: contractAddresses.testnet.DAI,
},
{
id: 3,
name: 'Test Token USD Coin',
symbol: 'USDC',
decimal: 6,
address: contractAddresses.testnet.USDC,
},
{
id: 4,
name: 'Wrapped ETH Test Token',
symbol: 'WETH',
decimal: 18,
address: contractAddresses.testnet.WETH,
},
{
id: 5,
name: 'CST',
symbol: 'CST',
decimal: 6,
address: contractAddresses.testnet.CST,
},
{
id: 6,
name: 'uSPON',
symbol: 'uSPON',
decimal: 6,
address: contractAddresses.testnet.uSPON,
},
],
mainnet: [
{
id: 2,
name: 'uSPON',
symbol: 'uSPON',
decimal: 6,
address: contractAddresses.mainnet.uSPON,
},
],
};
const DEFAULT_PAGE_SIZE = 10;
const GSEQ = '1';
const OSEQ = '1';
const SIGNATURE_DEADLINE = Number(process.env.SIGNATURE_DEADLINE) || 86400;
const isValidEthereumAddress = (address) => ethers.isAddress(address);
const getTokenDetails = (tokenInfo, networkType) => {
if (isValidEthereumAddress(tokenInfo)) {
return (tokenMap[networkType]?.find((token) => token.address.toLowerCase() === tokenInfo.toLowerCase()) || tokenMap[networkType][0]);
}
else {
return (tokenMap[networkType]?.find((token) => token.symbol.toLowerCase() === tokenInfo.toLowerCase()) || tokenMap[networkType][0]);
}
};
const requestPipeline = async ({ url, method, body = undefined, options = {}, }) => {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
try {
const res = await fetch(`${url}`, {
headers,
method,
body,
...options,
});
const contentType = res.headers.get('Content-Type');
const isJson = contentType && contentType.includes('application/json');
if (res.status === 500) {
throw new Error('Something went wrong');
}
if (res.status === 204 || res.status === 205) {
return null;
}
else if (isJson) {
return res.json();
}
else {
return res.text();
}
}
catch (error) {
throw error;
}
};
const initializeSigner = async ({ wallet }) => {
if (wallet) {
return { signer: wallet };
}
if (typeof window?.ethereum === 'undefined') {
throw new Error('Please install MetaMask');
}
try {
await window.ethereum.request({ method: 'eth_requestAccounts' });
}
catch (error) {
throw new Error('Failed to request Ethereum accounts ->' + error);
}
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
return { signer };
};
const replaceDomain = (url, newDomain) => {
try {
const parsedUrl = new URL(url);
const port = parsedUrl.port ? `:${parsedUrl.port}` : '';
let pathname = parsedUrl.pathname;
if (pathname.endsWith('/') && pathname !== '/') {
pathname = pathname.slice(0, -1);
}
if (pathname === '/') {
pathname = '';
}
return `${parsedUrl.protocol}//${newDomain}${port}${pathname}${parsedUrl.search}${parsedUrl.hash}`;
}
catch (err) {
console.error('Invalid URL:', err);
return url;
}
};
const errorMessages = {
// Escrow Contract Error Messages
TokenAlreadyRegistered: 'This token has already been registered.',
InvalidTokenAddress: 'The token address provided seems to be invalid.',
InvalidOwnerAddress: 'The owner address provided is incorrect or malformed.',
TokenNotRegistered: 'The token you are trying to access is not yet registered in the system. Please register it first.',
// Order Contract Error Messages
OrderNotFound: 'The order you are looking for was not found.',
OrderNotActive: 'The order is not active.',
InvalidAmount: 'The provided amount is invalid.',
InvalidBlockNumber: 'The provider duration is invalid.',
InsufficientBalance: 'You do not have sufficient balance in escrow.',
UnAuthorized: 'You are not authorized to perform this action',
// Lease Contract Error Messages
LeaseAlreadyTerminated: 'The lease is already terminated.',
OnlyTenantOrProvider: 'Only Tenant or Provider can close the lease.',
// Fizz Contract Error Messages
FizzAlreadyRegistered: 'This fizz node is already registered.',
StatusUnchanged: 'No changes detected in the fizz status.',
InactiveFizzNode: 'This fizz node is currently inactive.',
InvalidAddress: 'The address provided seems incorrect. Please verify it.',
TokenAlreadyAccepted: 'This token has already been accepted.',
RegistrationFeeNotPaid: 'The fizz registration fee is unpaid.',
UnregisteredToken: 'The token is unregistered.',
FizzNodeNotFound: 'We could not find the fizz node. Double-check the details and try again.',
TokenNotFound: 'The token was not found. Please verify and try again.',
InvalidUnit: 'The specified unit is invalid. Please correct it.',
// Provider Contract Error Messages
ProviderNotFound: 'Unable to locate the provider. Please check the details.',
ProviderNotActive: 'The provider is currently inactive.',
ProviderAlreadyRegistered: 'The provider is already registered.',
InactiveProvider: 'The provider is inactive.',
NotAuthorized: 'You are not authorized to perform this action.',
InvalidAttributes: 'The provided attributes are not valid.',
EmptyArray: 'No data was provided. The array is empty.',
ArrayMismatch: 'The arrays provided do not match.',
};
const handleContractError = (error, abi) => {
if (typeof error === 'object' &&
error !== null &&
'data' in error &&
typeof error.data === 'string') {
try {
const iface = new ethers.Interface(abi);
const decodedError = iface.parseError(error.data);
const errorMessage = decodedError ? errorMessages[decodedError.name] : '';
return errorMessage || 'An error occurred while processing your transaction.';
}
catch (decodeError) {
return 'Failed to decode the error.';
}
}
else {
return 'Transaction failed without revert data.';
}
};
var AccessControlManagerTestnet = [
{
inputs: [
],
stateMutability: "nonpayable",
type: "constructor"
},
{
inputs: [
],
name: "AccessControlBadConfirmation",
type: "error"
},
{
inputs: [
{
internalType: "address",
name: "account",
type: "address"
},
{
internalType: "bytes32",
name: "neededRole",
type: "bytes32"
}
],
name: "AccessControlUnauthorizedAccount",
type: "error"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "bytes32",
name: "role",
type: "bytes32"
},
{
indexed: true,
internalType: "bytes32",
name: "previousAdminRole",
type: "bytes32"
},
{
indexed: true,
internalType: "bytes32",
name: "newAdminRole",
type: "bytes32"
}
],
name: "RoleAdminChanged",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "bytes32",
name: "role",
type: "bytes32"
},
{
indexed: true,
internalType: "address",
name: "account",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "sender",
type: "address"
}
],
name: "RoleGranted",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "bytes32",
name: "role",
type: "bytes32"
},
{
indexed: true,
internalType: "address",
name: "account",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "sender",
type: "address"
}
],
name: "RoleRevoked",
type: "event"
},
{
inputs: [
],
name: "BID_CONTRACT_ROLE",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "DEFAULT_ADMIN_ROLE",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "MINTER_ROLE",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "SLASHER_ROLE",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "VERIFIER_ROLE",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "admin",
type: "address"
}
],
name: "addAdmin",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "bidContract",
type: "address"
}
],
name: "addBidContract",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "minter",
type: "address"
}
],
name: "addMinter",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "slasher",
type: "address"
}
],
name: "addSlasher",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "verifier",
type: "address"
}
],
name: "addVerifier",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "bytes32",
name: "role",
type: "bytes32"
}
],
name: "getRoleAdmin",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "bytes32",
name: "role",
type: "bytes32"
},
{
internalType: "address",
name: "account",
type: "address"
}
],
name: "grantRole",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "bytes32",
name: "role",
type: "bytes32"
},
{
internalType: "address",
name: "account",
type: "address"
}
],
name: "hasRole",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "account",
type: "address"
}
],
name: "isAdmin",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "account",
type: "address"
}
],
name: "isBidContract",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "account",
type: "address"
}
],
name: "isMinter",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "account",
type: "address"
}
],
name: "isSlasher",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "account",
type: "address"
}
],
name: "isVerifier",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "bidContract",
type: "address"
}
],
name: "removeBidContract",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "minter",
type: "address"
}
],
name: "removeMinter",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "slasher",
type: "address"
}
],
name: "removeSlasher",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "verifier",
type: "address"
}
],
name: "removeVerifier",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "bytes32",
name: "role",
type: "bytes32"
},
{
internalType: "address",
name: "callerConfirmation",
type: "address"
}
],
name: "renounceRole",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "bytes32",
name: "role",
type: "bytes32"
},
{
internalType: "address",
name: "account",
type: "address"
}
],
name: "revokeRole",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "bytes4",
name: "interfaceId",
type: "bytes4"
}
],
name: "supportsInterface",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
}
];
var TokenRegistryTestnet = [
{
inputs: [
{
internalType: "address",
name: "_access",
type: "address"
}
],
stateMutability: "nonpayable",
type: "constructor"
},
{
inputs: [
],
name: "InvalidOwnerAddress",
type: "error"
},
{
inputs: [
],
name: "InvalidTokenAddress",
type: "error"
},
{
inputs: [
],
name: "TokenAlreadyRegistered",
type: "error"
},
{
inputs: [
],
name: "TokenNotRegistered",
type: "error"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "OwnershipTransferred",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "tokenAddress",
type: "address"
},
{
indexed: true,
internalType: "uint128",
name: "decimals",
type: "uint128"
},
{
indexed: false,
internalType: "string",
name: "symbol",
type: "string"
},
{
indexed: false,
internalType: "uint256",
name: "minimumDeposit",
type: "uint256"
},
{
indexed: false,
internalType: "bool",
name: "isDefault",
type: "bool"
}
],
name: "TokenAdded",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "tokenAddress",
type: "address"
}
],
name: "TokenRemoved",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "string",
name: "ticker",
type: "string"
},
{
indexed: false,
internalType: "address",
name: "newTokenAddress",
type: "address"
}
],
name: "TokenUpdated",
type: "event"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "acceptedTokens",
outputs: [
{
internalType: "string",
name: "symbol",
type: "string"
},
{
internalType: "uint128",
name: "decimals",
type: "uint128"
},
{
internalType: "address",
name: "tokenAddress",
type: "address"
},
{
internalType: "uint256",
name: "minimumDeposit",
type: "uint256"
},
{
internalType: "bool",
name: "isDefault",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "accessControl",
outputs: [
{
internalType: "contract IAccessControlManager",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "string[]",
name: "_symbols",
type: "string[]"
},
{
internalType: "address[]",
name: "_tokens",
type: "address[]"
},
{
internalType: "uint128[]",
name: "_decimals",
type: "uint128[]"
},
{
internalType: "uint256[]",
name: "_minimumDeposits",
type: "uint256[]"
},
{
internalType: "bool[]",
name: "_isDefault",
type: "bool[]"
}
],
name: "addToken",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "getAllTokens",
outputs: [
{
components: [
{
internalType: "string",
name: "symbol",
type: "string"
},
{
internalType: "uint128",
name: "decimals",
type: "uint128"
},
{
internalType: "address",
name: "tokenAddress",
type: "address"
},
{
internalType: "uint256",
name: "minimumDeposit",
type: "uint256"
},
{
internalType: "bool",
name: "isDefault",
type: "bool"
}
],
internalType: "struct TokenRegistry.Token[]",
name: "",
type: "tuple[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "string",
name: "symbol",
type: "string"
}
],
name: "getTokenAddress",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_token",
type: "address"
}
],
name: "getTokenDetails",
outputs: [
{
components: [
{
internalType: "string",
name: "symbol",
type: "string"
},
{
internalType: "uint128",
name: "decimals",
type: "uint128"
},
{
internalType: "address",
name: "tokenAddress",
type: "address"
},
{
internalType: "uint256",
name: "minimumDeposit",
type: "uint256"
},
{
internalType: "bool",
name: "isDefault",
type: "bool"
}
],
internalType: "struct TokenRegistry.Token",
name: "",
type: "tuple"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "isAcceptedToken",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_token",
type: "address"
}
],
name: "isDefaultToken",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "owner",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_token",
type: "address"
}
],
name: "removeDefaultToken",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address[]",
name: "_token",
type: "address[]"
}
],
name: "removeTokens",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_token",
type: "address"
}
],
name: "setDefaultToken",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "string",
name: "",
type: "string"
}
],
name: "symbolToAddress",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
name: "tokens",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_newOwner",
type: "address"
}
],
name: "transferOwnership",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
}
];
var ProviderRegistryAbi = [
{
inputs: [
{
internalType: "address",
name: "_tokenRegistryAddress",
type: "address"
},
{
internalType: "address",
name: "_access",
type: "address"
}
],
stateMutability: "nonpayable",
type: "constructor"
},
{
inputs: [
],
name: "InvalidAddress",
type: "error"
},
{
inputs: [
],
name: "ProviderAlreadyRegistered",
type: "error"
},
{
inputs: [
],
name: "ProviderNotFound",
type: "error"
},
{
inputs: [
],
name: "StatusUnchanged",
type: "error"
},
{
inputs: [
],
name: "TokenAlreadyAccepted",
type: "error"
},
{
inputs: [
],
name: "TokenNotFound",
type: "error"
},
{
inputs: [
],
name: "UnauthorizedRegistration",
type: "error"
},
{
inputs: [
],
name: "UnregisteredToken",
type: "error"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
indexed: true,
internalType: "address",
name: "walletAddress",
type: "address"
},
{
indexed: false,
internalType: "string",
name: "spec",
type: "string"
},
{
indexed: false,
internalType: "string",
name: "hostUri",
type: "string"
},
{
indexed: false,
internalType: "string",
name: "certificate",
type: "string"
},
{
indexed: false,
internalType: "address[]",
name: "paymentsAccepted",
type: "address[]"
},
{
indexed: false,
internalType: "enum ProviderRegistry.ProviderStatus",
name: "status",
type: "uint8"
},
{
indexed: false,
internalType: "enum ProviderRegistry.TrustTier",
name: "tier",
type: "uint8"
},
{
indexed: false,
internalType: "uint256",
name: "joinTimestamp",
type: "uint256"
},
{
indexed: false,
internalType: "address",
name: "rewardWallet",
type: "address"
}
],
name: "ProviderAdded",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
indexed: false,
internalType: "string",
name: "certificate",
type: "string"
}
],
name: "ProviderCertificateUpdated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
indexed: false,
internalType: "string",
name: "hostUri",
type: "string"
}
],
name: "ProviderHostUriUpdated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
indexed: true,
internalType: "address",
name: "tokenAddress",
type: "address"
}
],
name: "ProviderPaymentAdded",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
indexed: true,
internalType: "address",
name: "tokenAddress",
type: "address"
}
],
name: "ProviderPaymentRemoved",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
}
],
name: "ProviderRemoved",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
indexed: false,
internalType: "address",
name: "rewardWallet",
type: "address"
}
],
name: "ProviderRewardWalletUpdated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
indexed: false,
internalType: "string",
name: "spec",
type: "string"
}
],
name: "ProviderSpecUpdated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
indexed: false,
internalType: "enum ProviderRegistry.ProviderStatus",
name: "status",
type: "uint8"
}
],
name: "ProviderStatusUpdated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "address",
name: "provider",
type: "address"
},
{
indexed: false,
internalType: "enum ProviderRegistry.TrustTier",
name: "tier",
type: "uint8"
}
],
name: "ProviderTierUpdated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "address",
name: "reward",
type: "address"
}
],
name: "RewardManagerAddressUpdated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_tokenRegistry",
type: "address"
}
],
name: "TokenRegistryContactUpdated",
type: "event"
},
{
inputs: [
],
name: "VERIFIER_ROLE",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "accessControl",
outputs: [
{
internalType: "contract IAccessControlManager",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_tokenAddress",
type: "address"
}
],
name: "addAcceptedPayment",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
components: [
{
internalType: "address",
name: "walletAddress",
type: "address"
},
{
internalType: "address[]",
name: "paymentsAccepted",
type: "address[]"
},
{
internalType: "string",
name: "spec",
type: "string"
},
{
internalType: "string",
name: "hostUri",
type: "string"
},
{
internalType: "string",
name: "certificate",
type: "string"
},
{
internalType: "address",
name: "rewardWallet",
type: "address"
}
],
internalType: "struct ProviderRegistry.ProviderParams",
name: "params",
type: "tuple"
}
],
name: "addProvider",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "addressToProviderId",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
components: [
{
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
internalType: "address",
name: "walletAddress",
type: "address"
},
{
internalType: "address[]",
name: "paymentsAccepted",
type: "address[]"
},
{
internalType: "string",
name: "spec",
type: "string"
},
{
internalType: "string",
name: "hostUri",
type: "string"
},
{
internalType: "string",
name: "certificate",
type: "string"
},
{
internalType: "enum ProviderRegistry.ProviderStatus",
name: "status",
type: "uint8"
},
{
internalType: "enum ProviderRegistry.TrustTier",
name: "tier",
type: "uint8"
},
{
internalType: "uint256",
name: "joinTimestamp",
type: "uint256"
},
{
internalType: "address",
name: "rewardWallet",
type: "address"
}
],
internalType: "struct ProviderRegistry.Provider[]",
name: "providerInfos",
type: "tuple[]"
}
],
name: "adminAddProviders",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_providerId",
type: "uint256"
},
{
internalType: "string",
name: "_spec",
type: "string"
}
],
name: "adminUpdateProviderSpec",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "getAllProviders",
outputs: [
{
components: [
{
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
internalType: "address",
name: "walletAddress",
type: "address"
},
{
internalType: "address[]",
name: "paymentsAccepted",
type: "address[]"
},
{
internalType: "string",
name: "spec",
type: "string"
},
{
internalType: "string",
name: "hostUri",
type: "string"
},
{
internalType: "string",
name: "certificate",
type: "string"
},
{
internalType: "enum ProviderRegistry.ProviderStatus",
name: "status",
type: "uint8"
},
{
internalType: "enum ProviderRegistry.TrustTier",
name: "tier",
type: "uint8"
},
{
internalType: "uint256",
name: "joinTimestamp",
type: "uint256"
},
{
internalType: "address",
name: "rewardWallet",
type: "address"
}
],
internalType: "struct ProviderRegistry.Provider[]",
name: "",
type: "tuple[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_providerId",
type: "uint256"
}
],
name: "getProvider",
outputs: [
{
internalType: "string",
name: "spec",
type: "string"
},
{
internalType: "string",
name: "hostUri",
type: "string"
},
{
internalType: "string",
name: "certificate",
type: "string"
},
{
internalType: "address[]",
name: "paymentsAccepted",
type: "address[]"
},
{
internalType: "enum ProviderRegistry.ProviderStatus",
name: "status",
type: "uint8"
},
{
internalType: "enum ProviderRegistry.TrustTier",
name: "tier",
type: "uint8"
},
{
internalType: "uint256",
name: "joinTimestamp",
type: "uint256"
},
{
internalType: "address",
name: "walletAddress",
type: "address"
},
{
internalType: "address",
name: "rewardWallet",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_rewardAddress",
type: "address"
}
],
name: "getProviderAddressByRewardAddress",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_walletAddress",
type: "address"
}
],
name: "getProviderByAddress",
outputs: [
{
internalType: "string",
name: "spec",
type: "string"
},
{
internalType: "string",
name: "hostUri",
type: "string"
},
{
internalType: "string",
name: "certificate",
type: "string"
},
{
internalType: "address[]",
name: "paymentsAccepted",
type: "address[]"
},
{
internalType: "enum ProviderRegistry.ProviderStatus",
name: "status",
type: "uint8"
},
{
internalType: "enum ProviderRegistry.TrustTier",
name: "tier",
type: "uint8"
},
{
internalType: "uint256",
name: "joinTimestamp",
type: "uint256"
},
{
internalType: "address",
name: "rewardWallet",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_walletAddress",
type: "address"
}
],
name: "getProviderId",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_walletAddress",
type: "address"
}
],
name: "getProviderRewardWallet",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_walletAddress",
type: "address"
}
],
name: "getProviderStatus",
outputs: [
{
internalType: "enum ProviderRegistry.ProviderStatus",
name: "",
type: "uint8"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_walletAddress",
type: "address"
}
],
name: "getProviderTrustTier",
outputs: [
{
internalType: "enum ProviderRegistry.TrustTier",
name: "",
type: "uint8"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_providerId",
type: "uint256"
}
],
name: "getProviderWallet",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_walletAddress",
type: "address"
}
],
name: "isActiveProvider",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_walletAddress",
type: "address"
}
],
name: "isRegisteredProvider",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_walletAddress",
type: "address"
},
{
internalType: "address",
name: "_tokenAddress",
type: "address"
}
],
name: "isTokenAcceptedByProvider",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "nextProviderId",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
},
{
internalType: "address",
name: "",
type: "address"
}
],
name: "providerAcceptedTokens",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "providerRewardManager",
outputs: [
{
internalType: "contract IProviderRewardsManager",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
name: "providers",
outputs: [
{
internalType: "uint256",
name: "providerId",
type: "uint256"
},
{
internalType: "address",
name: "walletAddress",
type: "address"
},
{
internalType: "string",
name: "spec",
type: "string"
},
{
internalType: "string",
name: "hostUri",
type: "string"
},
{
internalType: "string",
name: "certificate",
type: "string"
},
{
internalType: "enum ProviderRegistry.ProviderStatus",
name: "status",
type: "uint8"
},
{
internalType: "enum ProviderRegistry.TrustTier",
name: "tier",
type: "uint8"
},
{
internalType: "uint256",
name: "joinTimestamp",
type: "uint256"
},
{
internalType: "address",
name: "rewardWallet",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_tokenAddress",
type: "address"
}
],
name: "removeAcceptedPayment",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_providerId",
type: "uint256"
}
],
name: "removeProvider",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "rewardAddressToProviderId",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_providerAddress",
type: "address"
},
{
internalType: "enum ProviderRegistry.ProviderStatus",
name: "_status",
type: "uint8"
}
],
name: "setProviderStatus",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "tokenRegistry",
outputs: [
{
internalType: "contract ITokenRegistry",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "string",
name: "_certificate",
type: "string"
}
],
name: "updateProviderCertificate",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "string",
name: "_hostUri",
type: "string"
}
],
name: "updateProviderHostUri",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_rewardWallet",
type: "address"
}
],
name: "updateProviderRewardAddress",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "string",
name: "_spec",
type: "string"
}
],
name: "updateProviderSpec",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_provider",
type: "address"
},
{
internalType: "enum ProviderRegistry.TrustTier",
name: "_tier",
type: "uint8"
}
],
name: "updateProviderTier",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_rewardManager",
type: "address"
}
],
name: "updateRewardAdress",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_tokenRegistry",
type: "address"
}
],
name: "updateTokenRegistryContract",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
}
];
var ProviderAttributeRegistryAbi = [
{
inputs: [
{
internalType: "address",
name: "_providerRegistryAddress",
type: "address"
},
{
internalType: "address",
name: "_access",
type: "address"
}
],
stateMutability: "nonpayable",
type: "constructor"
},
{
inputs: [
],
name: "ArrayMismatch",
type: "error"
},
{
inputs: [
],
name: "DuplicateId",
type: "error"
},
{
inputs: [
],
name: "EmptyArray",
type: "error"
},
{
inputs: [
],
name: "InvalidAddress",
type: "error"
},
{
inputs: [
],
name: "InvalidUnit",
type: "error"
},
{
inputs: [
],
name: "NoPendingAttributes",
type: "error"
},
{
inputs: [
],
name: "ProviderNotActive",
type: "error"
},
{
inputs: [
],
name: "ProviderNotFound",
type: "error"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "submitter",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "totalProcessed",
type: "uint256"
},
{
indexed: false,
internalType: "uint256",
name: "successCount",
type: "uint256"
}
],
name: "BatchAttributesSubmitted",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "provider",
type: "address"
},
{
indexed: false,
internalType: "string",
name: "category",
type: "string"
},
{
components: [
{
internalType: "uint256",
name: "id",
type: "uint256"
},
{
internalType: "uint256",
name: "units",
type: "uint256"
}
],
indexed: false,
internalType: "struct ProviderAttributeRegistry.Attribute[]",
name: "attributes",
type: "tuple[]"
}
],
name: "ProviderAttributesApproved",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "provider",
type: "address"
},
{
indexed: false,
internalType: "string",
name: "category",
type: "string"
}
],
name: "ProviderAttributesRemoved",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "provider",
type: "address"
},
{
indexed: false,
internalType: "string",
name: "category",
type: "string"
},
{
indexed: false,
internalType: "uint256[]",
name: "ids",
type: "uint256[]"
},
{
indexed: false,
internalType: "uint256[]",
name: "units",
type: "uint256[]"
}
],
name: "ProviderAttributesSubmitted",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "address",
name: "providerRegistry",
type: "address"
}
],
name: "ProviderRegistryUpdated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "address",
name: "reward",
type: "address"
}
],
name: "RewardManagerAddressUpdated",
type: "event"
},
{
inputs: [
],
name: "VERIFIER_ROLE",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "accessControl",
outputs: [
{
internalType: "contract IAccessControlManager",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
in