diff --git a/public/assets/wallet.js b/public/assets/wallet.js index fc5b88a..890562c 100644 --- a/public/assets/wallet.js +++ b/public/assets/wallet.js @@ -49,11 +49,10 @@ window.IAPWallet = (function () { return eth().request({ method: 'eth_sendTransaction', params: [tx] }); } async function waitTx(hash) { - const c = await IAP.getConfig(); + // poll our own server (CSP-friendly); it relays the receipt from the RPC for (let i = 0; i < 60; i++) { - const r = await (await fetch(c.rpc, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'eth_getTransactionReceipt', params: [hash] }) })).json(); - if (r.result) return r.result; + const r = await (await fetch('/api/tx/' + hash)).json(); + if (r.found) return { status: r.status, blockNumber: r.blockNumber }; await new Promise(res => setTimeout(res, 2500)); } throw new Error('Timed out waiting for the transaction. Check the explorer.'); diff --git a/public/contract.html b/public/contract.html index 0136766..e6ab88e 100644 --- a/public/contract.html +++ b/public/contract.html @@ -5,7 +5,7 @@ The contract | InstantAdPay - +
@@ -129,8 +129,8 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.
- - - + + + diff --git a/public/index.html b/public/index.html index 835cb7c..0b62cdb 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,7 @@ InstantAdPay: advertise and earn, locked in code - + @@ -398,9 +398,9 @@ - - - - + + + + diff --git a/public/ledger.html b/public/ledger.html index 5ab5c5f..c54502b 100644 --- a/public/ledger.html +++ b/public/ledger.html @@ -5,7 +5,7 @@ Live ledger | InstantAdPay - +
@@ -25,8 +25,8 @@
InstantAdPay · how it works · contract source ↗
- - - + + + diff --git a/public/my.html b/public/my.html index 2582be6..4b956f7 100644 --- a/public/my.html +++ b/public/my.html @@ -4,7 +4,7 @@ Member area | InstantAdPay - + @@ -208,9 +208,9 @@ - - - - + + + + diff --git a/server.js b/server.js index 6da22ce..4f8cbfb 100644 --- a/server.js +++ b/server.js @@ -173,6 +173,14 @@ const server = http.createServer(async (req, res) => { req.on('close', () => feedClients.delete(res)); return; } + m = /^\/api\/tx\/(0x[0-9a-fA-F]{64})$/.exec(p); + if (m && req.method === 'GET') { + // receipt relay so the browser never talks to the RPC directly (CSP stays 'self') + try { + const r = await chain.rpc('eth_getTransactionReceipt', [m[1]]); + return json(res, 200, r ? { found: true, status: r.status, blockNumber: r.blockNumber } : { found: false }); + } catch (e) { return json(res, 200, { found: false, rpcError: true }); } + } if (p === '/api/sponsor' && req.method === 'GET') { const tok = parseCookies(req)['iap.sponsor'] || ''; const sponsorId = await resolveSponsorToken(tok);