aboutsummaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Expand)AuthorAgeFilesLines
* change in binance apiAdam Soltys2020-06-271-11/+6
* lnurl authAdam Soltys2020-06-232-21/+29
* move client version, update example config and schemaAdam Soltys2020-06-151-1/+1
* push notificationsAdam Soltys2020-06-132-37/+79
* reduce network trafficAdam Soltys2020-06-082-74/+35
* private key sweepAdam Soltys2020-05-291-1/+1
* address sweep wipAdam Soltys2020-05-261-1/+1
* log ip of failed socketAdam Soltys2020-05-181-5/+5
* Revert "drop recaptcha"Adam Soltys2020-05-162-24/+0
* safer socketsAdam Soltys2020-05-151-0/+3
* log id on closeAdam Soltys2020-05-151-3/+7
* catch close errorAdam Soltys2020-05-151-1/+1
* remove logAdam Soltys2020-05-151-1/+0
* check for null stringAdam Soltys2020-05-151-1/+2
* lintAdam Soltys2020-05-151-4/+4
* more socket loggingAdam Soltys2020-05-151-2/+3
* log tokenAdam Soltys2020-05-151-2/+2
* support opt-in to the different networksAdam Soltys2020-05-141-0/+1
* drop recaptchaAdam Soltys2020-05-142-0/+24
* use ws instead of socket.ioAdam Soltys2020-05-132-36/+47
* throw if user not foundAdam Soltys2020-05-111-0/+1
* drop fb, track ip's for faucetAdam Soltys2020-05-041-5/+0
* update account balance properly after lightning paymentAdam Soltys2020-04-291-10/+38
* log socket openAdam Soltys2020-04-281-1/+3
* include account in emitted payments objectsAdam Soltys2020-04-281-2/+10
* fix lightning paymentsAdam Soltys2020-04-281-3/+3
* select payments from current accountAdam Soltys2020-04-283-42/+44
* improved assets supportAdam Soltys2020-04-284-27/+68
* more statsAdam Soltys2020-04-171-1/+2
* send asset supportAdam Soltys2020-04-131-0/+163
* getuser utility functionAdam Soltys2020-04-133-30/+33
* unit fieldAdam Soltys2020-04-011-0/+1
* filter paymentsAdam Soltys2020-03-261-3/+8
* set socket id after user updateAdam Soltys2020-03-201-1/+1
* drop lnrpcAdam Soltys2020-03-112-40/+36
* refactorAdam Soltys2020-03-116-0/+359
* lnrpc refactorAdam Soltys2020-03-011-2/+1
* query routes and send to routeAdam Soltys2020-02-281-1/+1
* remove babel and eslintAdam Soltys2019-09-121-21/+19
* Removed dependency on forked moduleKevin Malakoff2019-06-141-0/+43
class="nx">record, user, unavailable, network = 'mainnet', pending } = {}) { storage.set('btc-wallet-network', network); const ui = { nameClaim: 'legacy', screen: 'wallet', nameEditOpen: true }; const calls = []; const state = { name: 'npub1test', domain: network === 'mainnet' ? 'coinos.io' : 'staging.coinos.io' }; globalThis.fetch = async (url, opts = {}) => { calls.push(String(url)); if (url.endsWith('/register')) { if (opts.method === 'DELETE') return Response.json({}); return Response.json(error ? { error } : {}, { status: error ? 409 : 200 }); } if (url.includes('/name/')) { if (pending) await pending; if (unavailable) throw new Error('offline'); return Response.json(record ?? { name: 'legacy', domain: 'coinos.io', taken: true, reserved: true }); } if (url.includes('/api/users/')) return user ? Response.json(user) : new Response('', { status: 404 }); throw new Error('unexpected request: ' + url); }; const feature = namesFeature({ h, ui, render() {}, toast() {}, brandHeader: () => null, wallet: { nostrPubkey: () => 'a'.repeat(64), nostrSign: async e => e, loadFeatureState: () => state, saveFeatureState() {}, }, hook: name => name === 'arkStaticAddress' ? 'ark-test-address' : null, }); const form = () => feature.namesClaimForm(); const submit = () => nodes(form()).find(n => n.tag === 'button' && n.props.class === 'btn-primary btn-block').props.onClick(); return { ui, calls, feature, form, submit }; } try { let s = setup({ user: { username: 'legacy', migrated: true } }); assert.equal(migration(s.form()), undefined); assert.equal(migration(s.feature.screenView()), undefined); assert.equal(s.calls.length, 0, 'opening the form does not check migration'); await s.submit(); assert.ok(migration(s.form()), 'legacy-only name offers migration after rejection'); s.ui.onb = { step: 'spend' }; migration(s.form()).props.onClick(); assert.equal(s.ui.onb.step, 'legacy', 'onboarding still reaches the migration instructions'); nodes(s.form()).find(n => n.tag === 'input').props.onInput({ target: { value: 'different' } }); assert.equal(migration(s.form()), undefined, 'editing the name removes the offer'); console.log('✓ migration is offered only after submitting a confirmed legacy-only name'); s = setup({ error: null }); await s.submit(); assert.equal(migration(s.form()), undefined); assert.ok(s.calls.every(url => url.endsWith('/register')), 'successful claims skip migration lookups'); console.log('✓ free names claim normally without a migration prompt'); s = setup({ record: { name: 'legacy', domain: 'coinos.io', taken: true, pubkey: 'b'.repeat(64) }, user: { username: 'legacy' } }); await s.submit(); assert.equal(migration(s.form()), undefined); assert.ok(!s.calls.some(url => url.includes('/api/users/')), 'already registered names never offer migration'); console.log('✓ migrated and other v3 names show the claim error without migration'); for (const options of [{ error: 'name is reserved' }, { unavailable: true }, { user: { username: 'someoneelse' } }, { record: {} }, { network: 'mutinynet', user: { username: 'legacy' } }, { error: 'signing timed out', user: { username: 'legacy' } }]) { s = setup(options); await s.submit(); assert.equal(migration(s.form()), undefined); } console.log('✓ reserved words, failed lookups, staging, and unrelated errors do not offer migration'); let release; s = setup({ user: { username: 'legacy' }, pending: new Promise(r => { release = r; }) }); const submission = s.submit(); s.ui.nameClaim = 'different'; release(); await submission; assert.equal(migration(s.form()), undefined, 'a late result cannot offer migration for a new draft'); console.log('✓ editing during submission cannot leave a stale migration offer'); s = setup({ error: 'name is reserved', user: { username: 'legacy', migrated: true } }); await assert.rejects(s.feature.namesClaimName('legacy', { quietProfile: true }), err => err.migrationName === 'legacy'); console.log('✓ profile saves receive the same confirmed migration result'); } finally { globalThis.fetch = originalFetch; } process.exit(0);