@reyaxyz/common 0.258.1 → 0.258.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/transactions/contractAddresses.js +1 -1
- package/dist/transactions/contractAddresses.js.map +1 -1
- package/dist/transactions/executeTransaction.js +2 -2
- package/dist/transactions/executeTransaction.js.map +1 -1
- package/dist/types/transactions/executeTransaction.d.ts.map +1 -1
- package/dist/types/utils/network.d.ts.map +1 -1
- package/dist/types/utils/sbt-helpers.d.ts +3 -1
- package/dist/types/utils/sbt-helpers.d.ts.map +1 -1
- package/dist/utils/network.js +6 -2
- package/dist/utils/network.js.map +1 -1
- package/dist/utils/sbt-helpers.js +11 -2
- package/dist/utils/sbt-helpers.js.map +1 -1
- package/package.json +2 -2
- package/src/transactions/contractAddresses.ts +1 -1
- package/src/transactions/executeTransaction.ts +4 -2
- package/src/utils/network.ts +6 -2
- package/src/utils/sbt-helpers.ts +12 -2
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -36,7 +36,7 @@ var addresses = (_a = {},
|
|
|
36
36
|
_c[ContractType.ORACLE_ADAPTERS_PROXY] = '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',
|
|
37
37
|
_c[ContractType.MULTICALL] = '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',
|
|
38
38
|
_c[ContractType.CAMELOT_YAK_ROUTER] = '0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',
|
|
39
|
-
_c[ContractType.REYA_SBTS] = '',
|
|
39
|
+
_c[ContractType.REYA_SBTS] = '0x14d7c1efc024e118df70b241afbd2447d37f1ed6',
|
|
40
40
|
_c),
|
|
41
41
|
_a);
|
|
42
42
|
var getAddress = function (chainId, contract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AqB,IACjC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,SAAS,IAAG,4CAA4C;QACtE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,SAAS,IAAG,4CAA4C;WACvE;OACF,CAAC;AACK,IAAM,UAAU,GAAG,UACxB,OAAe,EACf,YAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,6CAAsC,UAAU,CAAE,CAAC,CAAC;IACtE,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,kCAA2B,YAAY,cAAW,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["import { Address, ReyaChainId } from '../types';\n\nexport enum ContractType {\n CORE_PROXY = 'core_proxy',\n PASSIVE_POOL_PROXY = 'passive_pool_proxy',\n PERIPHERY_PROXY = 'periphery_proxy',\n CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',\n PASSIVE_PERP_PROXY = 'passive_perp_proxy',\n ORACLE_ADAPTERS_PROXY = 'oracle_adapters_proxy',\n MULTICALL = 'multicall',\n CAMELOT_YAK_ROUTER = 'camelot_yak_router',\n REYA_SBTS = 'reya_sbts',\n}\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.reyaCronos]: {\n [ContractType.CORE_PROXY]: '0xc6fb022962e1426f4e0ec9d2f8861c57926e9f72',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0x9a3a664987b88790a6fdc1632e3b607813fd94ff',\n [ContractType.PERIPHERY_PROXY]:\n '0x94ccae812f1647696754412082dd6684c2366a7f',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x9ec177fed042ef2307928be2f5cdbf663b20244b',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0xc501a2356703cd351703d68963c6f4136120f7cf',\n [ContractType.MULTICALL]: '0x5abde4f0af8eaf3c9967f7fa126e59a103357b5c',\n [ContractType.CAMELOT_YAK_ROUTER]:\n '0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',\n [ContractType.REYA_SBTS]: '0xc0092ea9179ace93b0cd8910958e335575562722',\n },\n [ReyaChainId.reyaNetwork]: {\n [ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0xb4b77d6180cc14472a9a7bdff01cc2459368d413',\n [ContractType.PERIPHERY_PROXY]:\n '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x27e5cb712334e101b3c232eb0be198baaa595f5f',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',\n [ContractType.MULTICALL]: '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',\n [ContractType.CAMELOT_YAK_ROUTER]:\n '0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',\n [ContractType.REYA_SBTS]: '0x14d7c1efc024e118df70b241afbd2447d37f1ed6',\n },\n};\nexport const getAddress = (\n chainId: number,\n contractName: ContractType,\n): Address => {\n const keyChainId = chainId.toString();\n\n if (!Object.keys(addresses).includes(keyChainId)) {\n throw new Error(`Unspecified addresses for chain id ${keyChainId}`);\n }\n\n const networkAddresses = addresses[chainId as ReyaChainId];\n if (!Object.keys(networkAddresses).includes(contractName)) {\n throw new Error(`Unspecified address for ${contractName} contract`);\n }\n\n return networkAddresses[contractName];\n};\n"]}
|
|
@@ -58,8 +58,8 @@ var txHelpers_1 = require("./txHelpers");
|
|
|
58
58
|
var utils_1 = require("../utils");
|
|
59
59
|
var ethers_2 = require("ethers");
|
|
60
60
|
exports.reyaChainIdRPCMapper = (_a = {},
|
|
61
|
-
_a[types_1.ReyaChainId.reyaNetwork] = 'https://rpc.reya.network',
|
|
62
|
-
_a[types_1.ReyaChainId.reyaCronos] = 'https://rpc.reya-cronos.gelato.digital',
|
|
61
|
+
_a[types_1.ReyaChainId.reyaNetwork] = 'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',
|
|
62
|
+
_a[types_1.ReyaChainId.reyaCronos] = 'https://rpc.reya-cronos.gelato.digital/263e76b89da84d478fd2b6e8783a1cfe',
|
|
63
63
|
_a);
|
|
64
64
|
var errorDecoder = ethers_decode_error_1.ErrorDecoder.create([Errors_json_1.abi]);
|
|
65
65
|
function estimateGas(signer, data, value, chainId, targetContract) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeTransaction.js","sourceRoot":"/","sources":["transactions/executeTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAuD;AACvD,kCAA0D;AAC1D,yDAA+D;AAC/D,kDAAyC;AACzC,2DAAmD;AAEnD,yCAA2C;AAC3C,kCAAmD;AACnD,iCAAmC;AAEtB,QAAA,oBAAoB;IAC/B,GAAC,mBAAW,CAAC,WAAW,IAAG,0BAA0B;IACrD,GAAC,mBAAW,CAAC,UAAU,IAAG,wCAAwC;QAClE;AAQF,IAAM,YAAY,GAAG,kCAAY,CAAC,MAAM,CAAC,C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MAAM,cAAN,MAAM,GAAI,6BAA6B,CAAC;IACnD,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,YAAY,CAAC,UAAkB;IACtC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAClD,CAAC;AAED,SAAsB,gBAAgB,CAAC,UAAkB;;;;YACjD,SAAS,GAAG,IAAI,kBAAS,CAAC,iBAAG,CAAC,CAAC;YAC/B,YAAY,GAAG,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YACtD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC1B,sBAAO,UAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,eAAK,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,CAAE,IAAI,iBAAiB,EAAC;;;CAC5E;AALD,4CAKC","sourcesContent":["import { ethers, JsonRpcSigner, Signer } from 'ethers';\nimport { MoneyInOutChainId, ReyaChainId } from '../types';\nimport { ContractType, getAddress } from './contractAddresses';\nimport { abi } from './abis/Errors.json';\nimport { ErrorDecoder } from 'ethers-decode-error';\nimport type { DecodedError } from 'ethers-decode-error';\nimport { getGasBuffer } from './txHelpers';\nimport { getPublicRpcUrlsOrThrow } from '../utils';\nimport { Interface } from 'ethers';\n\nexport const reyaChainIdRPCMapper: { [key: number]: string } = {\n [ReyaChainId.reyaNetwork]: 'https://rpc.reya.network',\n [ReyaChainId.reyaCronos]: 'https://rpc.reya-cronos.gelato.digital',\n};\n\nexport type Transaction = {\n from: string;\n to: string;\n data: string;\n value?: string;\n};\nconst errorDecoder = ErrorDecoder.create([abi]);\n\nexport async function estimateGas(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n): Promise<\n Transaction & {\n gasLimit: bigint;\n maxPriorityFeePerGas?: bigint;\n maxFeePerGas?: bigint;\n }\n> {\n const accountAddress = await signer.getAddress();\n\n return estimateGasGivenAddress(\n accountAddress,\n data,\n value,\n chainId,\n targetContract,\n );\n}\n\nexport async function estimateGasGivenAddress(\n accountAddress: string,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n): Promise<\n Transaction & {\n gasLimit: bigint;\n maxPriorityFeePerGas?: bigint;\n maxFeePerGas?: bigint;\n }\n> {\n const contractAddress = Object.values(ContractType).includes(\n targetContract as ContractType,\n )\n ? getAddress(chainId, targetContract as ContractType)\n : targetContract;\n\n const tx = {\n from: accountAddress, // @todo Update with relayer address\n to: contractAddress,\n data,\n ...(value && value !== '0' ? { value: value } : {}),\n };\n\n const gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit if fails to get estimate\n\n try {\n const provider = ethers.getDefaultProvider(reyaChainIdRPCMapper[chainId]);\n await provider.call(tx);\n } catch (error) {\n const decodedError = await errorDecoder.decode(error);\n const reason = customReasonMapper(decodedError);\n console.error(\n `Error simulating transaction account address ${accountAddress} reason ${decodedError?.name} ${decodedError} ${error}`,\n );\n throw new Error(reason);\n }\n\n if (Object.values(ReyaChainId).includes(chainId as ReyaChainId)) {\n const maxPriorityFeePerGas: bigint = BigInt('0');\n const maxFeePerGas: bigint = BigInt('100000000');\n return { ...tx, gasLimit, maxPriorityFeePerGas, maxFeePerGas };\n }\n\n return { ...tx, gasLimit };\n}\n\nexport async function estimateGasFromTxAndChainId(\n chainId: ReyaChainId | MoneyInOutChainId,\n tx: ethers.TransactionRequest,\n): Promise<bigint> {\n const rpcUrls = getPublicRpcUrlsOrThrow(chainId);\n let lastError = null;\n\n for (const url of rpcUrls) {\n try {\n const provider = new ethers.JsonRpcProvider(url);\n const estimation = await provider.estimateGas(tx);\n return addGasBuffer(estimation);\n } catch (error) {\n lastError = error;\n }\n }\n\n throw new Error('All RPC URLs failed; last error: ' + lastError);\n}\n\nexport async function estimateGasWithoutHardcoding(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n): Promise<\n Transaction & {\n gasLimit: bigint;\n maxPriorityFeePerGas?: bigint;\n maxFeePerGas?: bigint;\n }\n> {\n const accountAddress = await signer.getAddress();\n\n const contractAddress = Object.values(ContractType).includes(\n targetContract as ContractType,\n )\n ? getAddress(chainId, targetContract as ContractType)\n : targetContract;\n const tx = {\n from: accountAddress, // @todo Update with relayer address\n to: contractAddress,\n data,\n ...(value && value !== '0' ? { value: value } : {}),\n };\n\n let gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit if fails to get estimate\n\n try {\n const provider = ethers.getDefaultProvider(reyaChainIdRPCMapper[chainId]);\n const estimation = await provider.estimateGas(tx);\n gasLimit = addGasBuffer(estimation);\n } catch (error) {\n const decodedError = await errorDecoder.decode(error);\n const reason = customReasonMapper(decodedError);\n console.error(\n `Error simulating transaction account address ${accountAddress} reason ${decodedError?.name} ${decodedError} ${error}`,\n );\n throw new Error(reason);\n }\n\n if (Object.values(ReyaChainId).includes(chainId as ReyaChainId)) {\n const maxPriorityFeePerGas: bigint = BigInt('0');\n const maxFeePerGas: bigint = BigInt('100000000');\n return { ...tx, gasLimit, maxPriorityFeePerGas, maxFeePerGas };\n }\n\n return { ...tx, gasLimit };\n}\n\nasync function estimateGasExternalChains(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n): Promise<\n Transaction & {\n gasLimit: bigint;\n maxPriorityFeePerGas?: bigint;\n maxFeePerGas?: bigint;\n }\n> {\n const accountAddress = await signer.getAddress();\n\n const contractAddress = Object.values(ContractType).includes(\n targetContract as ContractType,\n )\n ? getAddress(chainId, targetContract as ContractType)\n : targetContract;\n const tx = {\n from: accountAddress,\n to: contractAddress,\n data,\n ...(value && value !== '0' ? { value: value } : {}),\n };\n\n let gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit if fails to get estimate\n\n try {\n const gasEstimate = await signer.estimateGas(tx);\n gasLimit = getGasBuffer(gasEstimate);\n } catch (error) {\n const decodedError = await errorDecoder.decode(error);\n const reason = customReasonMapper(decodedError);\n console.error(\n `Error simulating external transaction account address ${accountAddress} reason ${decodedError?.name} ${decodedError} ${error}`,\n );\n throw new Error(reason);\n }\n\n if (Object.values(ReyaChainId).includes(chainId as ReyaChainId)) {\n const maxPriorityFeePerGas: bigint = BigInt('0');\n const maxFeePerGas: bigint = BigInt('100000000');\n return { ...tx, gasLimit, maxPriorityFeePerGas, maxFeePerGas };\n }\n\n return { ...tx, gasLimit };\n}\nexport async function executeTransaction(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n) {\n const txData = await estimateGasExternalChains(\n signer,\n data,\n value,\n chainId,\n targetContract,\n );\n\n try {\n const txResponse = await signer.sendTransaction(txData);\n const txReceipt = await txResponse.wait();\n return txReceipt;\n } catch (error) {\n console.warn(error);\n throw new Error('Transaction Execution Error');\n }\n}\nconst customReasonMapper = ({ name, reason }: DecodedError): string => {\n switch (name) {\n case 'SignatureInvalid':\n return `Invalid signature. Please refresh page and try again`;\n case 'StalePriceDetected':\n return `Price not updated, please try again a bit later`;\n case 'SmallOrderSize':\n return `Order size below minimum`;\n case 'DustyOrderSize':\n return `Order amount is not divisible by trade size spacing`;\n case 'AccountBelowIM':\n return `Account below required margin`;\n default:\n // This handles the non-custom errors\n return reason ?? 'Error executing transaction';\n }\n};\n\nfunction addGasBuffer(estimation: bigint): bigint {\n return (estimation * BigInt(120)) / BigInt(100);\n}\n\nexport async function decodeErrorBytes(returnData: string): Promise<string> {\n const INTERFACE = new Interface(abi);\n const decodedError = INTERFACE.parseError(returnData);\n console.log(decodedError);\n return `${decodedError?.name}: ${decodedError?.args}` || 'Error not found';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"executeTransaction.js","sourceRoot":"/","sources":["transactions/executeTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAuD;AACvD,kCA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,kBAAkB;YACrB,OAAO,sDAAsD,CAAC;QAChE,KAAK,oBAAoB;YACvB,OAAO,iDAAiD,CAAC;QAC3D,KAAK,gBAAgB;YACnB,OAAO,0BAA0B,CAAC;QACpC,KAAK,gBAAgB;YACnB,OAAO,qDAAqD,CAAC;QAC/D,KAAK,gBAAgB;YACnB,OAAO,+BAA+B,CAAC;QACzC;YACE,qCAAqC;YACrC,OAAO,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,6BAA6B,CAAC;IACnD,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,YAAY,CAAC,UAAkB;IACtC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAClD,CAAC;AAED,SAAsB,gBAAgB,CAAC,UAAkB;;;;YACjD,SAAS,GAAG,IAAI,kBAAS,CAAC,iBAAG,CAAC,CAAC;YAC/B,YAAY,GAAG,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YACtD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC1B,sBAAO,UAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,eAAK,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,CAAE,IAAI,iBAAiB,EAAC;;;CAC5E;AALD,4CAKC","sourcesContent":["import { ethers, JsonRpcSigner, Signer } from 'ethers';\nimport { MoneyInOutChainId, ReyaChainId } from '../types';\nimport { ContractType, getAddress } from './contractAddresses';\nimport { abi } from './abis/Errors.json';\nimport { ErrorDecoder } from 'ethers-decode-error';\nimport type { DecodedError } from 'ethers-decode-error';\nimport { getGasBuffer } from './txHelpers';\nimport { getPublicRpcUrlsOrThrow } from '../utils';\nimport { Interface } from 'ethers';\n\nexport const reyaChainIdRPCMapper: { [key: number]: string } = {\n [ReyaChainId.reyaNetwork]:\n 'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',\n [ReyaChainId.reyaCronos]:\n 'https://rpc.reya-cronos.gelato.digital/263e76b89da84d478fd2b6e8783a1cfe',\n};\n\nexport type Transaction = {\n from: string;\n to: string;\n data: string;\n value?: string;\n};\nconst errorDecoder = ErrorDecoder.create([abi]);\n\nexport async function estimateGas(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n): Promise<\n Transaction & {\n gasLimit: bigint;\n maxPriorityFeePerGas?: bigint;\n maxFeePerGas?: bigint;\n }\n> {\n const accountAddress = await signer.getAddress();\n\n return estimateGasGivenAddress(\n accountAddress,\n data,\n value,\n chainId,\n targetContract,\n );\n}\n\nexport async function estimateGasGivenAddress(\n accountAddress: string,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n): Promise<\n Transaction & {\n gasLimit: bigint;\n maxPriorityFeePerGas?: bigint;\n maxFeePerGas?: bigint;\n }\n> {\n const contractAddress = Object.values(ContractType).includes(\n targetContract as ContractType,\n )\n ? getAddress(chainId, targetContract as ContractType)\n : targetContract;\n\n const tx = {\n from: accountAddress, // @todo Update with relayer address\n to: contractAddress,\n data,\n ...(value && value !== '0' ? { value: value } : {}),\n };\n\n const gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit if fails to get estimate\n\n try {\n const provider = ethers.getDefaultProvider(reyaChainIdRPCMapper[chainId]);\n await provider.call(tx);\n } catch (error) {\n const decodedError = await errorDecoder.decode(error);\n const reason = customReasonMapper(decodedError);\n console.error(\n `Error simulating transaction account address ${accountAddress} reason ${decodedError?.name} ${decodedError} ${error}`,\n );\n throw new Error(reason);\n }\n\n if (Object.values(ReyaChainId).includes(chainId as ReyaChainId)) {\n const maxPriorityFeePerGas: bigint = BigInt('0');\n const maxFeePerGas: bigint = BigInt('100000000');\n return { ...tx, gasLimit, maxPriorityFeePerGas, maxFeePerGas };\n }\n\n return { ...tx, gasLimit };\n}\n\nexport async function estimateGasFromTxAndChainId(\n chainId: ReyaChainId | MoneyInOutChainId,\n tx: ethers.TransactionRequest,\n): Promise<bigint> {\n const rpcUrls = getPublicRpcUrlsOrThrow(chainId);\n let lastError = null;\n\n for (const url of rpcUrls) {\n try {\n const provider = new ethers.JsonRpcProvider(url);\n const estimation = await provider.estimateGas(tx);\n return addGasBuffer(estimation);\n } catch (error) {\n lastError = error;\n }\n }\n\n throw new Error('All RPC URLs failed; last error: ' + lastError);\n}\n\nexport async function estimateGasWithoutHardcoding(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n): Promise<\n Transaction & {\n gasLimit: bigint;\n maxPriorityFeePerGas?: bigint;\n maxFeePerGas?: bigint;\n }\n> {\n const accountAddress = await signer.getAddress();\n\n const contractAddress = Object.values(ContractType).includes(\n targetContract as ContractType,\n )\n ? getAddress(chainId, targetContract as ContractType)\n : targetContract;\n const tx = {\n from: accountAddress, // @todo Update with relayer address\n to: contractAddress,\n data,\n ...(value && value !== '0' ? { value: value } : {}),\n };\n\n let gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit if fails to get estimate\n\n try {\n const provider = ethers.getDefaultProvider(reyaChainIdRPCMapper[chainId]);\n const estimation = await provider.estimateGas(tx);\n gasLimit = addGasBuffer(estimation);\n } catch (error) {\n const decodedError = await errorDecoder.decode(error);\n const reason = customReasonMapper(decodedError);\n console.error(\n `Error simulating transaction account address ${accountAddress} reason ${decodedError?.name} ${decodedError} ${error}`,\n );\n throw new Error(reason);\n }\n\n if (Object.values(ReyaChainId).includes(chainId as ReyaChainId)) {\n const maxPriorityFeePerGas: bigint = BigInt('0');\n const maxFeePerGas: bigint = BigInt('100000000');\n return { ...tx, gasLimit, maxPriorityFeePerGas, maxFeePerGas };\n }\n\n return { ...tx, gasLimit };\n}\n\nasync function estimateGasExternalChains(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n): Promise<\n Transaction & {\n gasLimit: bigint;\n maxPriorityFeePerGas?: bigint;\n maxFeePerGas?: bigint;\n }\n> {\n const accountAddress = await signer.getAddress();\n\n const contractAddress = Object.values(ContractType).includes(\n targetContract as ContractType,\n )\n ? getAddress(chainId, targetContract as ContractType)\n : targetContract;\n const tx = {\n from: accountAddress,\n to: contractAddress,\n data,\n ...(value && value !== '0' ? { value: value } : {}),\n };\n\n let gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit if fails to get estimate\n\n try {\n const gasEstimate = await signer.estimateGas(tx);\n gasLimit = getGasBuffer(gasEstimate);\n } catch (error) {\n const decodedError = await errorDecoder.decode(error);\n const reason = customReasonMapper(decodedError);\n console.error(\n `Error simulating external transaction account address ${accountAddress} reason ${decodedError?.name} ${decodedError} ${error}`,\n );\n throw new Error(reason);\n }\n\n if (Object.values(ReyaChainId).includes(chainId as ReyaChainId)) {\n const maxPriorityFeePerGas: bigint = BigInt('0');\n const maxFeePerGas: bigint = BigInt('100000000');\n return { ...tx, gasLimit, maxPriorityFeePerGas, maxFeePerGas };\n }\n\n return { ...tx, gasLimit };\n}\nexport async function executeTransaction(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n targetContract: ContractType | string,\n) {\n const txData = await estimateGasExternalChains(\n signer,\n data,\n value,\n chainId,\n targetContract,\n );\n\n try {\n const txResponse = await signer.sendTransaction(txData);\n const txReceipt = await txResponse.wait();\n return txReceipt;\n } catch (error) {\n console.warn(error);\n throw new Error('Transaction Execution Error');\n }\n}\nconst customReasonMapper = ({ name, reason }: DecodedError): string => {\n switch (name) {\n case 'SignatureInvalid':\n return `Invalid signature. Please refresh page and try again`;\n case 'StalePriceDetected':\n return `Price not updated, please try again a bit later`;\n case 'SmallOrderSize':\n return `Order size below minimum`;\n case 'DustyOrderSize':\n return `Order amount is not divisible by trade size spacing`;\n case 'AccountBelowIM':\n return `Account below required margin`;\n default:\n // This handles the non-custom errors\n return reason ?? 'Error executing transaction';\n }\n};\n\nfunction addGasBuffer(estimation: bigint): bigint {\n return (estimation * BigInt(120)) / BigInt(100);\n}\n\nexport async function decodeErrorBytes(returnData: string): Promise<string> {\n const INTERFACE = new Interface(abi);\n const decodedError = INTERFACE.parseError(returnData);\n console.log(decodedError);\n return `${decodedError?.name}: ${decodedError?.args}` || 'Error not found';\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeTransaction.d.ts","sourceRoot":"/","sources":["transactions/executeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAc,MAAM,qBAAqB,CAAC;AAQ/D,eAAO,MAAM,oBAAoB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"executeTransaction.d.ts","sourceRoot":"/","sources":["transactions/executeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAc,MAAM,qBAAqB,CAAC;AAQ/D,eAAO,MAAM,oBAAoB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAKzD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,GAAG,aAAa,EAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,YAAY,G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"file":"network.d.ts","sourceRoot":"/","sources":["utils/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE1E,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,WAAW,CAK/D;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,cAAc,GAClB,iBAAiB,EAAE,CAkBrB;AAED,wBAAgB,mCAAmC,CACjD,iBAAiB,EAAE,iBAAiB,GACnC,WAAW,CAab;AAED,wBAAgB,oCAAoC,CAClD,WAAW,EAAE,WAAW,GACvB,iBAAiB,EAAE,CAWrB;AAED,eAAO,MAAM,oBAAoB,EAAE;KAChC,GAAG,IAAI,iBAAiB,GAAG,WAAW,GAAG,MAAM;CAYjD,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,iBAAiB,GAAG,WAAW,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"/","sources":["utils/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE1E,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,WAAW,CAK/D;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,cAAc,GAClB,iBAAiB,EAAE,CAkBrB;AAED,wBAAgB,mCAAmC,CACjD,iBAAiB,EAAE,iBAAiB,GACnC,WAAW,CAab;AAED,wBAAgB,oCAAoC,CAClD,WAAW,EAAE,WAAW,GACvB,iBAAiB,EAAE,CAWrB;AAED,eAAO,MAAM,oBAAoB,EAAE;KAChC,GAAG,IAAI,iBAAiB,GAAG,WAAW,GAAG,MAAM;CAYjD,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,iBAAiB,GAAG,WAAW,EAAE,MAAM,EAAE,CA+D1E,CAAC;AAgBF,eAAO,MAAM,gBAAgB,WACnB,MAAM,WACL,iBAAiB,KACzB,MAAM,GAAG,IAQX,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAClB,iBAAiB,GAAG,WAAW,KACvC,MAAM,EAQR,CAAC;AAEF,eAAO,MAAM,uBAAuB,YACzB,iBAAiB,GAAG,WAAW,KACvC,MAAM,EAQR,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { BigNumberish } from 'ethers';
|
|
3
|
-
|
|
3
|
+
import { ReyaChainId } from '../types';
|
|
4
|
+
export declare const SBT_ROOT: Record<ReyaChainId, string>;
|
|
5
|
+
export declare const getSbtRoot: (reyaChainId: ReyaChainId) => string;
|
|
4
6
|
export declare const SBT_MINT_DEADLINE = 1743508800;
|
|
5
7
|
export type SbtLeafInfo = {
|
|
6
8
|
account: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sbt-helpers.d.ts","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"sbt-helpers.d.ts","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAKhD,CAAC;AAEF,eAAO,MAAM,UAAU,gBAAiB,WAAW,WAElD,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,OAAO,YAAa,MAAM,oBAAoB,MAAM,KAAG,MAQnE,CAAC;AAEF,eAAO,MAAM,aAAa,YACf,MAAM,cACH,MAAM,oBACA,MAAM,KACvB,YASF,CAAC"}
|
package/dist/utils/network.js
CHANGED
|
@@ -63,7 +63,9 @@ exports.chainIdToExplorerURL = (_a = {},
|
|
|
63
63
|
_a);
|
|
64
64
|
// TODO: make this non-export
|
|
65
65
|
exports.ChainRpcUrls = (_b = {},
|
|
66
|
-
_b[types_1.ReyaChainId.reyaNetwork] = [
|
|
66
|
+
_b[types_1.ReyaChainId.reyaNetwork] = [
|
|
67
|
+
'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',
|
|
68
|
+
],
|
|
67
69
|
_b[types_1.MoneyInOutChainId.ethereumMainnet] = [
|
|
68
70
|
'https://mainnet.gateway.tenderly.co',
|
|
69
71
|
'https://eth.llamarpc.com',
|
|
@@ -105,7 +107,9 @@ exports.ChainRpcUrls = (_b = {},
|
|
|
105
107
|
'https://base.gateway.tenderly.co/2LHAD54IBvgXiVQdhE9mIF',
|
|
106
108
|
],
|
|
107
109
|
// Add the rest of the mainnet URLs above
|
|
108
|
-
_b[types_1.ReyaChainId.reyaCronos] = [
|
|
110
|
+
_b[types_1.ReyaChainId.reyaCronos] = [
|
|
111
|
+
'https://rpc.reya-cronos.gelato.digital/263e76b89da84d478fd2b6e8783a1cfe',
|
|
112
|
+
],
|
|
109
113
|
_b[types_1.MoneyInOutChainId.arbitrumSepolia] = [
|
|
110
114
|
'https://sepolia-rollup.arbitrum.io/rpc',
|
|
111
115
|
'https://endpoints.omniatech.io/v1/arbitrum/sepolia/public',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"/","sources":["utils/network.ts"],"names":[],"mappings":";;;;AAAA,kCAA0E;AAE1E,SAAgB,cAAc,CAAC,GAAmB;IAChD,IAAI,GAAG,KAAK,YAAY;QAAE,OAAO,mBAAW,CAAC,WAAW,CAAC;IACzD,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,mBAAW,CAAC,UAAU,CAAC;IAElD,MA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BAAgB,GAAG,UAC9B,OAAwC;IAExC,IAAM,OAAO,GAAG,oBAAY,CAAC,OAAO,CAAC,CAAC;IAEtC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,gBAAgB,oBAU3B;AAEK,IAAM,uBAAuB,GAAG,UACrC,OAAwC;IAExC,IAAM,OAAO,GAAG,IAAA,wBAAgB,EAAC,OAAO,CAAC,CAAC;IAE1C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,+CAA+C,GAAG,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,uBAAuB,2BAUlC","sourcesContent":["import { ApplicationEnv, MoneyInOutChainId, ReyaChainId } from '../types';\n\nexport function getReyaNetwork(env: ApplicationEnv): ReyaChainId {\n if (env === 'production') return ReyaChainId.reyaNetwork;\n if (env === 'test') return ReyaChainId.reyaCronos;\n\n throw new Error('Unknown env for getReyaNetwork');\n}\n\nexport function getMoneyInOutNetworks(\n env: ApplicationEnv,\n): MoneyInOutChainId[] {\n if (env === 'production')\n return [\n MoneyInOutChainId.ethereumMainnet,\n MoneyInOutChainId.opMainnet,\n MoneyInOutChainId.polygonMainnet,\n MoneyInOutChainId.arbitrumOne,\n MoneyInOutChainId.baseMainnet,\n ];\n\n if (env === 'test')\n return [\n MoneyInOutChainId.ethereumSepolia,\n MoneyInOutChainId.opSepolia,\n MoneyInOutChainId.arbitrumSepolia,\n ];\n\n throw new Error('Unknown env for getMoneyInOutNetworks');\n}\n\nexport function getReyaNetworkFromMoneyInOutChainId(\n moneyInOutChainId: MoneyInOutChainId,\n): ReyaChainId {\n if (\n getMoneyInOutNetworks(ApplicationEnv.PRODUCTION).includes(moneyInOutChainId)\n ) {\n return getReyaNetwork(ApplicationEnv.PRODUCTION);\n }\n if (getMoneyInOutNetworks(ApplicationEnv.TEST).includes(moneyInOutChainId)) {\n return getReyaNetwork(ApplicationEnv.TEST);\n }\n\n throw new Error(\n `Unknown money in out network in getReyaNetworkFromMoneyInOutChainId: ${moneyInOutChainId}`,\n );\n}\n\nexport function getMoneyInOutNetworksFromReyaChainId(\n reyaChainId: ReyaChainId,\n): MoneyInOutChainId[] {\n if (getReyaNetwork(ApplicationEnv.PRODUCTION) === reyaChainId) {\n return getMoneyInOutNetworks(ApplicationEnv.PRODUCTION);\n }\n if (getReyaNetwork(ApplicationEnv.TEST) === reyaChainId) {\n return getMoneyInOutNetworks(ApplicationEnv.TEST);\n }\n\n throw new Error(\n `Unknown money in out network in getMoneyInOutNetworksFromReyaChainId: ${reyaChainId}`,\n );\n}\n\nexport const chainIdToExplorerURL: {\n [key in MoneyInOutChainId | ReyaChainId]: string;\n} = {\n [MoneyInOutChainId.ethereumMainnet]: 'https://etherscan.io',\n [MoneyInOutChainId.opMainnet]: 'https://optimistic.etherscan.io',\n [MoneyInOutChainId.polygonMainnet]: 'https://polygonscan.com',\n [MoneyInOutChainId.arbitrumOne]: 'https://arbiscan.io',\n [MoneyInOutChainId.baseMainnet]: 'https://basescan.org',\n [MoneyInOutChainId.arbitrumSepolia]: 'https://sepolia.arbiscan.io',\n [MoneyInOutChainId.opSepolia]: 'https://sepolia-optimism.etherscan.io',\n [MoneyInOutChainId.ethereumSepolia]: 'https://sepolia.etherscan.io',\n [ReyaChainId.reyaNetwork]: 'https://explorer.reya.network',\n [ReyaChainId.reyaCronos]: 'https://reya-cronos.blockscout.com',\n};\n\n// TODO: make this non-export\nexport const ChainRpcUrls: Record<MoneyInOutChainId | ReyaChainId, string[]> = {\n [ReyaChainId.reyaNetwork]: ['https://rpc.reya.network'],\n [MoneyInOutChainId.ethereumMainnet]: [\n 'https://mainnet.gateway.tenderly.co',\n 'https://eth.llamarpc.com',\n 'https://eth-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://eth-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://eth-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://mainnet.gateway.tenderly.co/69U6LoF0URUv5CfuIU7FdL',\n ],\n [MoneyInOutChainId.opMainnet]: [\n 'https://mainnet.optimism.io',\n 'https://optimism.llamarpc.com',\n 'https://opt-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://opt-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://opt-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://optimism.gateway.tenderly.co/69LkAPTI3LODcBAdtz9wQC',\n ],\n [MoneyInOutChainId.polygonMainnet]: [\n 'https://polygon-rpc.com',\n 'https://gateway.tenderly.co/public/polygon',\n 'https://polygon-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://polygon-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://polygon-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://polygon.gateway.tenderly.co/7Qw4fTY4kf3v02LjJjWyvZ',\n ],\n [MoneyInOutChainId.arbitrumOne]: [\n 'https://arb1.arbitrum.io/rpc',\n 'https://arbitrum.llamarpc.com',\n 'https://arb-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://arb-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://arb-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://arbitrum.gateway.tenderly.co/1wQGK6nNPTbSc7asucAbzA',\n ],\n [MoneyInOutChainId.baseMainnet]: [\n 'https://mainnet.base.org',\n 'https://base.llamarpc.com',\n 'https://base-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://base-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://base-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://base.gateway.tenderly.co/2LHAD54IBvgXiVQdhE9mIF',\n ],\n // Add the rest of the mainnet URLs above\n [ReyaChainId.reyaCronos]: ['https://rpc.reya-cronos.gelato.digital'],\n [MoneyInOutChainId.arbitrumSepolia]: [\n 'https://sepolia-rollup.arbitrum.io/rpc',\n 'https://endpoints.omniatech.io/v1/arbitrum/sepolia/public',\n 'https://arbitrum-sepolia.gateway.tenderly.co/4YMRN8fKu2SV1JSNsGlbMZ',\n ],\n [MoneyInOutChainId.opSepolia]: [\n 'https://sepolia.optimism.io',\n 'https://optimism-sepolia.blockpi.network/v1/rpc/public',\n 'https://optimism-sepolia.gateway.tenderly.co/2nXBEGPk57CotvTJMjIMK7',\n ],\n [MoneyInOutChainId.ethereumSepolia]: [\n 'https://sepolia.gateway.tenderly.co',\n 'https://ethereum-sepolia.blockpi.network/v1/rpc/public',\n 'https://sepolia.gateway.tenderly.co/1u2yZV1rdVLpgOeHwD1Z8M',\n ],\n};\n\nconst ALCHEMY_BASE_RPC_URL: Record<MoneyInOutChainId, string> = {\n // mainnet\n [MoneyInOutChainId.ethereumMainnet]: 'https://eth-mainnet.g.alchemy.com/v2',\n [MoneyInOutChainId.opMainnet]: 'https://opt-mainnet.g.alchemy.com/v2',\n [MoneyInOutChainId.polygonMainnet]:\n 'https://polygon-mainnet.g.alchemy.com/v2',\n [MoneyInOutChainId.arbitrumOne]: 'https://arb-mainnet.g.alchemy.com/v2',\n [MoneyInOutChainId.baseMainnet]: 'https://base-mainnet.g.alchemy.com/v2',\n // testnet\n [MoneyInOutChainId.arbitrumSepolia]: 'https://arb-sepolia.g.alchemy.com/v2',\n [MoneyInOutChainId.opSepolia]: 'https://opt-sepolia.g.alchemy.com/v2',\n [MoneyInOutChainId.ethereumSepolia]: 'https://eth-sepolia.g.alchemy.com/v2',\n};\n\nexport const getAlchemyRpcUrl = (\n apiKey: string,\n chainId: MoneyInOutChainId,\n): string | null => {\n const rpcUrl = ALCHEMY_BASE_RPC_URL[chainId];\n\n if (!rpcUrl) {\n return null;\n }\n\n return `${rpcUrl}/${apiKey}`;\n};\n\nexport const getPublicRpcUrls = (\n chainId: MoneyInOutChainId | ReyaChainId,\n): string[] => {\n const rpcUrls = ChainRpcUrls[chainId];\n\n if (!rpcUrls) {\n return [];\n }\n\n return rpcUrls;\n};\n\nexport const getPublicRpcUrlsOrThrow = (\n chainId: MoneyInOutChainId | ReyaChainId,\n): string[] => {\n const rpcUrls = getPublicRpcUrls(chainId);\n\n if (rpcUrls.length === 0) {\n throw new Error('No public RPC URLs configured for the chain: ' + chainId);\n }\n\n return rpcUrls;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"/","sources":["utils/network.ts"],"names":[],"mappings":";;;;AAAA,kCAA0E;AAE1E,SAAgB,cAAc,CAAC,GAAmB;IAChD,IAAI,GAAG,KAAK,YAAY;QAAE,OAAO,mBAAW,CAAC,WAAW,CAAC;IACzD,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,mBAAW,CAAC,UAAU,CAAC;IAElD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;AACpD,CAAC;AALD,wCAKC;AAED,SAAgB,qBAAqB,CACnC,GAAmB;IAEnB,IAAI,GAAG,KAAK,YAAY;QACtB,OAAO;YACL,yBAAiB,CAAC,eAAe;YACjC,yBAAiB,CAAC,SAAS;YAC3B,yBAAiB,CAAC,cAAc;YAChC,yBAAiB,CAAC,WAAW;YAC7B,yBAAiB,CAAC,WAAW;SAC9B,CAAC;IAEJ,IAAI,G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AAC,OAAO,CAAC,CAAC;IAE1C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,+CAA+C,GAAG,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,uBAAuB,2BAUlC","sourcesContent":["import { ApplicationEnv, MoneyInOutChainId, ReyaChainId } from '../types';\n\nexport function getReyaNetwork(env: ApplicationEnv): ReyaChainId {\n if (env === 'production') return ReyaChainId.reyaNetwork;\n if (env === 'test') return ReyaChainId.reyaCronos;\n\n throw new Error('Unknown env for getReyaNetwork');\n}\n\nexport function getMoneyInOutNetworks(\n env: ApplicationEnv,\n): MoneyInOutChainId[] {\n if (env === 'production')\n return [\n MoneyInOutChainId.ethereumMainnet,\n MoneyInOutChainId.opMainnet,\n MoneyInOutChainId.polygonMainnet,\n MoneyInOutChainId.arbitrumOne,\n MoneyInOutChainId.baseMainnet,\n ];\n\n if (env === 'test')\n return [\n MoneyInOutChainId.ethereumSepolia,\n MoneyInOutChainId.opSepolia,\n MoneyInOutChainId.arbitrumSepolia,\n ];\n\n throw new Error('Unknown env for getMoneyInOutNetworks');\n}\n\nexport function getReyaNetworkFromMoneyInOutChainId(\n moneyInOutChainId: MoneyInOutChainId,\n): ReyaChainId {\n if (\n getMoneyInOutNetworks(ApplicationEnv.PRODUCTION).includes(moneyInOutChainId)\n ) {\n return getReyaNetwork(ApplicationEnv.PRODUCTION);\n }\n if (getMoneyInOutNetworks(ApplicationEnv.TEST).includes(moneyInOutChainId)) {\n return getReyaNetwork(ApplicationEnv.TEST);\n }\n\n throw new Error(\n `Unknown money in out network in getReyaNetworkFromMoneyInOutChainId: ${moneyInOutChainId}`,\n );\n}\n\nexport function getMoneyInOutNetworksFromReyaChainId(\n reyaChainId: ReyaChainId,\n): MoneyInOutChainId[] {\n if (getReyaNetwork(ApplicationEnv.PRODUCTION) === reyaChainId) {\n return getMoneyInOutNetworks(ApplicationEnv.PRODUCTION);\n }\n if (getReyaNetwork(ApplicationEnv.TEST) === reyaChainId) {\n return getMoneyInOutNetworks(ApplicationEnv.TEST);\n }\n\n throw new Error(\n `Unknown money in out network in getMoneyInOutNetworksFromReyaChainId: ${reyaChainId}`,\n );\n}\n\nexport const chainIdToExplorerURL: {\n [key in MoneyInOutChainId | ReyaChainId]: string;\n} = {\n [MoneyInOutChainId.ethereumMainnet]: 'https://etherscan.io',\n [MoneyInOutChainId.opMainnet]: 'https://optimistic.etherscan.io',\n [MoneyInOutChainId.polygonMainnet]: 'https://polygonscan.com',\n [MoneyInOutChainId.arbitrumOne]: 'https://arbiscan.io',\n [MoneyInOutChainId.baseMainnet]: 'https://basescan.org',\n [MoneyInOutChainId.arbitrumSepolia]: 'https://sepolia.arbiscan.io',\n [MoneyInOutChainId.opSepolia]: 'https://sepolia-optimism.etherscan.io',\n [MoneyInOutChainId.ethereumSepolia]: 'https://sepolia.etherscan.io',\n [ReyaChainId.reyaNetwork]: 'https://explorer.reya.network',\n [ReyaChainId.reyaCronos]: 'https://reya-cronos.blockscout.com',\n};\n\n// TODO: make this non-export\nexport const ChainRpcUrls: Record<MoneyInOutChainId | ReyaChainId, string[]> = {\n [ReyaChainId.reyaNetwork]: [\n 'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',\n ],\n [MoneyInOutChainId.ethereumMainnet]: [\n 'https://mainnet.gateway.tenderly.co',\n 'https://eth.llamarpc.com',\n 'https://eth-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://eth-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://eth-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://mainnet.gateway.tenderly.co/69U6LoF0URUv5CfuIU7FdL',\n ],\n [MoneyInOutChainId.opMainnet]: [\n 'https://mainnet.optimism.io',\n 'https://optimism.llamarpc.com',\n 'https://opt-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://opt-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://opt-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://optimism.gateway.tenderly.co/69LkAPTI3LODcBAdtz9wQC',\n ],\n [MoneyInOutChainId.polygonMainnet]: [\n 'https://polygon-rpc.com',\n 'https://gateway.tenderly.co/public/polygon',\n 'https://polygon-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://polygon-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://polygon-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://polygon.gateway.tenderly.co/7Qw4fTY4kf3v02LjJjWyvZ',\n ],\n [MoneyInOutChainId.arbitrumOne]: [\n 'https://arb1.arbitrum.io/rpc',\n 'https://arbitrum.llamarpc.com',\n 'https://arb-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://arb-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://arb-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://arbitrum.gateway.tenderly.co/1wQGK6nNPTbSc7asucAbzA',\n ],\n [MoneyInOutChainId.baseMainnet]: [\n 'https://mainnet.base.org',\n 'https://base.llamarpc.com',\n 'https://base-mainnet.g.alchemy.com/v2/Tkk3-2tTcsCLnFa4dSSUkpZsDyOH55Ar',\n 'https://base-mainnet.g.alchemy.com/v2/Bin_D_qtJLCqvFyzt-0SxZRWTL423_tg',\n 'https://base-mainnet.g.alchemy.com/v2/A21_W1GwGu775PCAoQbj_pJgBPzIgAzv',\n 'https://base.gateway.tenderly.co/2LHAD54IBvgXiVQdhE9mIF',\n ],\n // Add the rest of the mainnet URLs above\n [ReyaChainId.reyaCronos]: [\n 'https://rpc.reya-cronos.gelato.digital/263e76b89da84d478fd2b6e8783a1cfe',\n ],\n [MoneyInOutChainId.arbitrumSepolia]: [\n 'https://sepolia-rollup.arbitrum.io/rpc',\n 'https://endpoints.omniatech.io/v1/arbitrum/sepolia/public',\n 'https://arbitrum-sepolia.gateway.tenderly.co/4YMRN8fKu2SV1JSNsGlbMZ',\n ],\n [MoneyInOutChainId.opSepolia]: [\n 'https://sepolia.optimism.io',\n 'https://optimism-sepolia.blockpi.network/v1/rpc/public',\n 'https://optimism-sepolia.gateway.tenderly.co/2nXBEGPk57CotvTJMjIMK7',\n ],\n [MoneyInOutChainId.ethereumSepolia]: [\n 'https://sepolia.gateway.tenderly.co',\n 'https://ethereum-sepolia.blockpi.network/v1/rpc/public',\n 'https://sepolia.gateway.tenderly.co/1u2yZV1rdVLpgOeHwD1Z8M',\n ],\n};\n\nconst ALCHEMY_BASE_RPC_URL: Record<MoneyInOutChainId, string> = {\n // mainnet\n [MoneyInOutChainId.ethereumMainnet]: 'https://eth-mainnet.g.alchemy.com/v2',\n [MoneyInOutChainId.opMainnet]: 'https://opt-mainnet.g.alchemy.com/v2',\n [MoneyInOutChainId.polygonMainnet]:\n 'https://polygon-mainnet.g.alchemy.com/v2',\n [MoneyInOutChainId.arbitrumOne]: 'https://arb-mainnet.g.alchemy.com/v2',\n [MoneyInOutChainId.baseMainnet]: 'https://base-mainnet.g.alchemy.com/v2',\n // testnet\n [MoneyInOutChainId.arbitrumSepolia]: 'https://arb-sepolia.g.alchemy.com/v2',\n [MoneyInOutChainId.opSepolia]: 'https://opt-sepolia.g.alchemy.com/v2',\n [MoneyInOutChainId.ethereumSepolia]: 'https://eth-sepolia.g.alchemy.com/v2',\n};\n\nexport const getAlchemyRpcUrl = (\n apiKey: string,\n chainId: MoneyInOutChainId,\n): string | null => {\n const rpcUrl = ALCHEMY_BASE_RPC_URL[chainId];\n\n if (!rpcUrl) {\n return null;\n }\n\n return `${rpcUrl}/${apiKey}`;\n};\n\nexport const getPublicRpcUrls = (\n chainId: MoneyInOutChainId | ReyaChainId,\n): string[] => {\n const rpcUrls = ChainRpcUrls[chainId];\n\n if (!rpcUrls) {\n return [];\n }\n\n return rpcUrls;\n};\n\nexport const getPublicRpcUrlsOrThrow = (\n chainId: MoneyInOutChainId | ReyaChainId,\n): string[] => {\n const rpcUrls = getPublicRpcUrls(chainId);\n\n if (rpcUrls.length === 0) {\n throw new Error('No public RPC URLs configured for the chain: ' + chainId);\n }\n\n return rpcUrls;\n};\n"]}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSbtTokenId = exports.getLeaf = exports.SBT_MINT_DEADLINE = exports.SBT_ROOT = void 0;
|
|
4
|
+
exports.getSbtTokenId = exports.getLeaf = exports.SBT_MINT_DEADLINE = exports.getSbtRoot = exports.SBT_ROOT = void 0;
|
|
4
5
|
var ethers_1 = require("ethers");
|
|
5
|
-
|
|
6
|
+
var types_1 = require("../types");
|
|
7
|
+
exports.SBT_ROOT = (_a = {},
|
|
8
|
+
_a[types_1.ReyaChainId.reyaNetwork] = '0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52',
|
|
9
|
+
_a[types_1.ReyaChainId.reyaCronos] = '0x01f4d29a3aca5cb40663851d2d40d605636dd6448f251d77765dd0e40c422136',
|
|
10
|
+
_a);
|
|
11
|
+
var getSbtRoot = function (reyaChainId) {
|
|
12
|
+
return exports.SBT_ROOT[reyaChainId];
|
|
13
|
+
};
|
|
14
|
+
exports.getSbtRoot = getSbtRoot;
|
|
6
15
|
exports.SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000
|
|
7
16
|
var getLeaf = function (address, tokenRootCounter) {
|
|
8
17
|
var messageHash = ethers_1.ethers.keccak256(ethers_1.ethers.solidityPacked(['address', 'uint256'], [address, tokenRootCounter.toString()]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sbt-helpers.js","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sbt-helpers.js","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";;;;AAAA,iCAA8C;AAC9C,kCAAuC;AAE1B,QAAA,QAAQ;IACnB,GAAC,mBAAW,CAAC,WAAW,IACtB,oEAAoE;IACtE,GAAC,mBAAW,CAAC,UAAU,IACrB,oEAAoE;QACtE;AAEK,IAAM,UAAU,GAAG,UAAC,WAAwB;IACjD,OAAO,gBAAQ,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEW,QAAA,iBAAiB,GAAG,UAAU,CAAC,CAAC,oCAAoC;AAO1E,IAAM,OAAO,GAAG,UAAC,OAAe,EAAE,gBAAwB;IAC/D,IAAM,WAAW,GAAG,eAAM,CAAC,SAAS,CAClC,eAAM,CAAC,cAAc,CACnB,CAAC,SAAS,EAAE,SAAS,CAAC,EACtB,CAAC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CACvC,CACF,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AARW,QAAA,OAAO,WAQlB;AAEK,IAAM,aAAa,GAAG,UAC3B,OAAe,EACf,UAAkB,EAClB,gBAAwB;IAExB,OAAO,eAAM,CAAC,QAAQ,CACpB,eAAM,CAAC,SAAS,CACd,eAAM,CAAC,cAAc,CACnB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EACjC,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CACnD,CACF,CACF,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB","sourcesContent":["import { ethers, BigNumberish } from 'ethers';\nimport { ReyaChainId } from '../types';\n\nexport const SBT_ROOT: Record<ReyaChainId, string> = {\n [ReyaChainId.reyaNetwork]:\n '0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52',\n [ReyaChainId.reyaCronos]:\n '0x01f4d29a3aca5cb40663851d2d40d605636dd6448f251d77765dd0e40c422136',\n};\n\nexport const getSbtRoot = (reyaChainId: ReyaChainId) => {\n return SBT_ROOT[reyaChainId];\n};\n\nexport const SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000\n\nexport type SbtLeafInfo = {\n account: string;\n tokenRootCounter: number;\n};\n\nexport const getLeaf = (address: string, tokenRootCounter: number): Buffer => {\n const messageHash = ethers.keccak256(\n ethers.solidityPacked(\n ['address', 'uint256'],\n [address, tokenRootCounter.toString()],\n ),\n );\n return Buffer.from(messageHash.slice(2), 'hex');\n};\n\nexport const getSbtTokenId = (\n account: string,\n merkleRoot: string,\n tokenRootCounter: number,\n): BigNumberish => {\n return ethers.toBigInt(\n ethers.keccak256(\n ethers.solidityPacked(\n ['address', 'bytes32', 'uint256'],\n [account, merkleRoot, tokenRootCounter.toString()],\n ),\n ),\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/common",
|
|
3
|
-
"version": "0.258.
|
|
3
|
+
"version": "0.258.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
45
45
|
},
|
|
46
46
|
"packageManager": "pnpm@8.3.1",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "cd300c6a473312df240cc12ea1c30c5cabc4c425"
|
|
48
48
|
}
|
|
@@ -45,7 +45,7 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
|
45
45
|
[ContractType.MULTICALL]: '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',
|
|
46
46
|
[ContractType.CAMELOT_YAK_ROUTER]:
|
|
47
47
|
'0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',
|
|
48
|
-
[ContractType.REYA_SBTS]: '',
|
|
48
|
+
[ContractType.REYA_SBTS]: '0x14d7c1efc024e118df70b241afbd2447d37f1ed6',
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
export const getAddress = (
|
|
@@ -9,8 +9,10 @@ import { getPublicRpcUrlsOrThrow } from '../utils';
|
|
|
9
9
|
import { Interface } from 'ethers';
|
|
10
10
|
|
|
11
11
|
export const reyaChainIdRPCMapper: { [key: number]: string } = {
|
|
12
|
-
[ReyaChainId.reyaNetwork]:
|
|
13
|
-
|
|
12
|
+
[ReyaChainId.reyaNetwork]:
|
|
13
|
+
'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',
|
|
14
|
+
[ReyaChainId.reyaCronos]:
|
|
15
|
+
'https://rpc.reya-cronos.gelato.digital/263e76b89da84d478fd2b6e8783a1cfe',
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export type Transaction = {
|
package/src/utils/network.ts
CHANGED
|
@@ -78,7 +78,9 @@ export const chainIdToExplorerURL: {
|
|
|
78
78
|
|
|
79
79
|
// TODO: make this non-export
|
|
80
80
|
export const ChainRpcUrls: Record<MoneyInOutChainId | ReyaChainId, string[]> = {
|
|
81
|
-
[ReyaChainId.reyaNetwork]: [
|
|
81
|
+
[ReyaChainId.reyaNetwork]: [
|
|
82
|
+
'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',
|
|
83
|
+
],
|
|
82
84
|
[MoneyInOutChainId.ethereumMainnet]: [
|
|
83
85
|
'https://mainnet.gateway.tenderly.co',
|
|
84
86
|
'https://eth.llamarpc.com',
|
|
@@ -120,7 +122,9 @@ export const ChainRpcUrls: Record<MoneyInOutChainId | ReyaChainId, string[]> = {
|
|
|
120
122
|
'https://base.gateway.tenderly.co/2LHAD54IBvgXiVQdhE9mIF',
|
|
121
123
|
],
|
|
122
124
|
// Add the rest of the mainnet URLs above
|
|
123
|
-
[ReyaChainId.reyaCronos]: [
|
|
125
|
+
[ReyaChainId.reyaCronos]: [
|
|
126
|
+
'https://rpc.reya-cronos.gelato.digital/263e76b89da84d478fd2b6e8783a1cfe',
|
|
127
|
+
],
|
|
124
128
|
[MoneyInOutChainId.arbitrumSepolia]: [
|
|
125
129
|
'https://sepolia-rollup.arbitrum.io/rpc',
|
|
126
130
|
'https://endpoints.omniatech.io/v1/arbitrum/sepolia/public',
|
package/src/utils/sbt-helpers.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { ethers, BigNumberish } from 'ethers';
|
|
2
|
+
import { ReyaChainId } from '../types';
|
|
3
|
+
|
|
4
|
+
export const SBT_ROOT: Record<ReyaChainId, string> = {
|
|
5
|
+
[ReyaChainId.reyaNetwork]:
|
|
6
|
+
'0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52',
|
|
7
|
+
[ReyaChainId.reyaCronos]:
|
|
8
|
+
'0x01f4d29a3aca5cb40663851d2d40d605636dd6448f251d77765dd0e40c422136',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const getSbtRoot = (reyaChainId: ReyaChainId) => {
|
|
12
|
+
return SBT_ROOT[reyaChainId];
|
|
13
|
+
};
|
|
2
14
|
|
|
3
|
-
export const SBT_ROOT =
|
|
4
|
-
'0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52';
|
|
5
15
|
export const SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000
|
|
6
16
|
|
|
7
17
|
export type SbtLeafInfo = {
|