diff --git a/.github/.ubiquibot-config.yml b/.github/.ubiquibot-config.yml new file mode 100644 index 00000000..33ed93c4 --- /dev/null +++ b/.github/.ubiquibot-config.yml @@ -0,0 +1,149 @@ +plugins: + - uses: + - plugin: https://ubiquibot-command-wallet-development.ubiquity.workers.dev + - uses: + - plugin: https://ubiquibot-command-query-user-development.ubiquity.workers.dev + with: + allowPublicQuery: true + - uses: + - plugin: https://ubiquibot-assistive-pricing-development.ubiquity.workers.dev + with: + labels: + time: + - "Time: <1 Hour" + - "Time: <2 Hours" + - "Time: <4 Hours" + - "Time: <1 Day" + - "Time: <1 Week" + - "Time: <1 Month" + priority: + - "Priority: 1 (Normal)" + - "Priority: 2 (Medium)" + - "Priority: 3 (High)" + - "Priority: 4 (Urgent)" + - "Priority: 5 (Emergency)" + basePriceMultiplier: 2 + publicAccessControl: + setLabel: true + fundExternalClosedIssue: false + - skipBotEvents: false + uses: + - plugin: ubiquibot/conversation-rewards@development + # we don't skip bot events so conversation rewards triggered by the bot also run + with: + evmNetworkId: 100 + evmPrivateEncrypted: "bd5AFnSCO6c5jJyPifpOfr5Zys29RE7SyXkEU3akT13RtGmYDrqGIGuvJQyH53HA5dIba7PL5bXfll0JebmwXYe5gHIXSGX80WuGMDHh0cFfeGjHhmUXe8kkZ1OT2De9qRpqejJcEzdfi-8XNAvP7cQu2Vt-7RNnPw" # https://github.com/ubiquibot/conversation-rewards/pull/111#issuecomment-2348639931 + erc20RewardToken: "0xC6ed4f520f6A4e4DC27273509239b7F8A68d2068" + incentives: + contentEvaluator: + enabled: true + userExtractor: + enabled: true + redeemTask: true + dataPurge: + enabled: true + formattingEvaluator: + multipliers: + - role: [ ISSUE_SPECIFICATION ] + multiplier: 3 + rewards: + regex: + "\\b\\w+\\b": 0.1 + html: + br: 0 + code: 5 + p: 1 + em: 0 + img: 5 + strong: 0 + blockquote: 0 + h1: 1 + h2: 1 + h3: 1 + h4: 1 + h5: 1 + h6: 1 + a: 5 + li: 1 + td: 1 + hr: 0 + - role: [ ISSUE_AUTHOR ] + multiplier: 1 + rewards: + regex: + "\\b\\w+\\b": 0.2 + - role: [ ISSUE_ASSIGNEE ] + multiplier: 1 + rewards: + regex: + "\\b\\w+\\b": 0.1 + - role: [ ISSUE_COLLABORATOR ] + multiplier: 1 + rewards: + regex: + "\\b\\w+\\b": 0.1 + - role: [ ISSUE_CONTRIBUTOR ] + multiplier: 0.25 + rewards: + regex: + "\\b\\w+\\b": 0.1 + - role: [ PULL_SPECIFICATION ] + multiplier: 0 + rewards: + regex: + "\\b\\w+\\b": 0 + - role: [ PULL_AUTHOR ] + multiplier: 0 + rewards: + regex: + "\\b\\w+\\b": 0.2 + - role: [ PULL_ASSIGNEE ] + multiplier: 1 + rewards: + regex: + "\\b\\w+\\b": 0.1 + - role: [ PULL_COLLABORATOR ] + multiplier: 1 + rewards: + regex: + "\\b\\w+\\b": 0.1 + - role: [ PULL_CONTRIBUTOR ] + multiplier: 0.25 + rewards: + regex: + "\\b\\w+\\b": 0.1 + permitGeneration: + enabled: true + githubComment: + post: true + debug: false + - uses: + - plugin: ubiquibot/user-activity-watcher@development + with: + watch: + optOut: + - ubiquibot + - launch-party + - staging + - production + - uses: + - plugin: ubiquibot/automated-merging@development + with: + approvalsRequired: + collaborator: 1 + mergeTimeout: + collaborator: "3.5 days" + repos: + ignore: + - ubiquibot + - launch-party + - staging + - production + - uses: + - plugin: https://ubiquibot-command-start-stop-development.ubiquity.workers.dev + with: + reviewDelayTolerance: "3 Days" + taskStaleTimeoutDuration: "30 Days" + startRequiresWallet: true # default is true + - uses: + - plugin: ubiquibot/issue-comment-embeddings@development diff --git a/static/scripts/rewards/cirip/ens-lookup.ts b/static/scripts/rewards/cirip/ens-lookup.ts index e0fece59..bf945dcc 100644 --- a/static/scripts/rewards/cirip/ens-lookup.ts +++ b/static/scripts/rewards/cirip/ens-lookup.ts @@ -1,10 +1,5 @@ -import { ethers } from "ethers"; -import abi from "../abis/cirip.json"; -import { fetchEns } from "./fetch-ens"; import { queryReverseEns } from "./query-reverse-ens"; -export const reverseEnsInterface = new ethers.utils.Interface(abi); - // addEventListener("fetch", event => { // event.respondWith(handleRequest(event.request).catch(err => new Response(err.stack, { status: 500 }))); // }); @@ -24,30 +19,12 @@ export async function ensLookup(addr: string, networkId: number) { // let response = ""; try { reverseRecord = await queryReverseEns(address, networkId); - const responseParsed = JSON.parse(reverseRecord).result; - const _reverseRecord = ethers.utils.defaultAbiCoder.decode([ethers.utils.ParamType.from("string[]")], responseParsed); - reverseRecord = _reverseRecord[0][0]; } catch (e) { console.error(e); // throw "Error contacting ethereum node. \nCause: '" + e + "'. \nResponse: " + response; } - const allDomains = await fetchEns(address); - - if (reverseRecord == "") { - reverseRecord = null; - } - - // if reverse record is set, validate addr owns this domain. - if (reverseRecord != null && !allDomains.includes(reverseRecord)) { - console.warn("Failed to validate! Reverse record set to " + reverseRecord + ", but user does not own this name."); - reverseRecord = null; - } - - return { - reverseRecord: reverseRecord, - domains: allDomains, - }; + return reverseRecord; // new Response(JSON.stringify(response), { // headers: { // "Content-Type": "application/json;charset=UTF-8", diff --git a/static/scripts/rewards/cirip/fetch-ens.ts b/static/scripts/rewards/cirip/fetch-ens.ts deleted file mode 100644 index ba3ba46c..00000000 --- a/static/scripts/rewards/cirip/fetch-ens.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { queryGraph } from "./query-graph"; - -export async function fetchEns(address: string) { - const endpoint = "https://api.thegraph.com/subgraphs/name/ensdomains/ens"; - const query = `{ - domains(where:{owner:"${address.toLowerCase()}"}) { - name - } - }`; - const res = await queryGraph(endpoint, query); - return res.data.domains.map((domain: { name: string }) => domain.name); -} diff --git a/static/scripts/rewards/cirip/query-graph.ts b/static/scripts/rewards/cirip/query-graph.ts deleted file mode 100644 index 8df99d5d..00000000 --- a/static/scripts/rewards/cirip/query-graph.ts +++ /dev/null @@ -1,12 +0,0 @@ -export async function queryGraph(endpoint: string | URL | Request, query: string) { - const response = await fetch(endpoint, { - method: "POST", - headers: { - "Content-Type": "application/json", - Accept: "application/json", - }, - body: JSON.stringify({ query }), - }); - - return response.json(); -} diff --git a/static/scripts/rewards/cirip/query-reverse-ens.ts b/static/scripts/rewards/cirip/query-reverse-ens.ts index b56c1256..b294c1db 100644 --- a/static/scripts/rewards/cirip/query-reverse-ens.ts +++ b/static/scripts/rewards/cirip/query-reverse-ens.ts @@ -1,6 +1,8 @@ import { app } from "../app-state"; import { useRpcHandler } from "../web3/use-rpc-handler"; -import { reverseEnsInterface } from "./ens-lookup"; +import { ethers } from "ethers"; + +const mainnetRpcUrl = "https://eth.drpc.org"; export async function queryReverseEns(address: string, networkId: number) { // Try to get the ENS name from localStorage @@ -12,33 +14,20 @@ export async function queryReverseEns(address: string, networkId: number) { if (cachedEnsName) return cachedEnsName; } - if (cachedEnsName) { + // Let's drop the old cache. + if (cachedEnsName && !cachedEnsName.trim().startsWith("{")) { // If the ENS name is in localStorage, return it return cachedEnsName; } else { // If the ENS name is not in localStorage, fetch it from the API - const data = reverseEnsInterface.encodeFunctionData("getNames", [[address.substring(2)]]); - - const response = await fetch(endpoint, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - jsonrpc: "2.0", - id: "1", - method: "eth_call", - params: [{ to: "0x3671aE578E63FdF66ad4F3E12CC0c0d71Ac7510C", data: data }, "latest"], - }), - }); + const web3Provider = new ethers.providers.JsonRpcProvider(mainnetRpcUrl); + const ensName = await web3Provider.lookupAddress(address); - if (!response.ok) { + if (ensName === null) { console.error("ENS lookup failed: API request failed"); return ""; } - const ensName = await response.text(); - // Store the ENS name in localStorage for future use localStorage.setItem(address, ensName); diff --git a/static/scripts/rewards/render-transaction/render-ens-name.ts b/static/scripts/rewards/render-transaction/render-ens-name.ts index 810df96d..0bb98ce2 100644 --- a/static/scripts/rewards/render-transaction/render-ens-name.ts +++ b/static/scripts/rewards/render-transaction/render-ens-name.ts @@ -20,16 +20,7 @@ type EnsParams = export async function renderEnsName({ element, address, tokenAddress, tokenView, networkId }: EnsParams): Promise { let href: string = ""; try { - const resolved = await ensLookup(address, networkId); - let ensName: undefined | string; - if (resolved.reverseRecord) { - ensName = resolved.reverseRecord; - } else if (resolved.domains.length) { - const domain = resolved.domains.shift(); - if (domain) { - ensName = domain; - } - } + const ensName = await ensLookup(address, networkId); if (ensName) { if (tokenView) { href = `${app.currentExplorerUrl}/token/${tokenAddress}?a=${address}`; diff --git a/static/styles/rewards/media-queries.css b/static/styles/rewards/media-queries.css index 8b9a9bcb..42c7b597 100644 --- a/static/styles/rewards/media-queries.css +++ b/static/styles/rewards/media-queries.css @@ -51,8 +51,8 @@ header span:first-child::after { /* Landscape */ @media screen and (orientation: landscape) { body { - width: 100vw; /* 100% of viewport width */ - max-width: 100vw; /* prevents any overflow issues */ + width: 100%; /* 100% of viewport width */ + max-width: 100%; /* prevents any overflow issues */ overflow-x: hidden; /* prevents horizontal scrolling */ padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); diff --git a/static/styles/rewards/pay.css b/static/styles/rewards/pay.css index f271ed99..38dafb7e 100644 --- a/static/styles/rewards/pay.css +++ b/static/styles/rewards/pay.css @@ -23,6 +23,17 @@ box-sizing: border-box; } +html { + display:block; + width: 100%; + height: 100%; +} + +body, main { + width: 100%; + height: 100%; +} + a { color: #808080; } @@ -30,11 +41,12 @@ a { body { /* min-height: 100vh; */ /* height: calc(100 * var(--vh)); */ + overflow: hidden; } body, main { - max-width: 100vw; + max-width: 100%; display: flex; flex-direction: column; justify-content: center; @@ -42,7 +54,7 @@ main { } main { - width: 100vw; + width: 100%; position: relative; } @@ -136,7 +148,7 @@ header a:hover #logo { main { display: flex; flex-direction: column; - height: 100vh; /* adjust this according to your needs */ + height: 100%; /* adjust this according to your needs */ } header {