Snapshot of accumulated work-in-progress on top of the baseline commit. This session — retire Tier B from the wallet shell (single-tier model, glossary "Tiers & trust"): - SendFlow.tsx: BCH-only; removed the non-functional Tier-B send path, the D-4/D-5 raw-BCH co-display, and the ADR-0013 friction ladder. - ArtemisionScreen.tsx: Create wizard collapsed to a single 5-step on-chain genesis flow; tier-selection step + Tier-B branch (prepareTierBImport) deleted. - QuickActions.tsx / SettingsScreen.tsx: receive note reworded; "Send friction thresholds" + "Tier explainer" rows removed; registry-trust note reworded. - Verified: tsc clean, vitest 74/74, full preview walkthrough, no console errors. Pre-existing uncommitted work also folded in: - USDm -> FIATm family rename/reorg (Parameters/FIATm/, design records) - ~130 chipnet + sim-fiatm scripts (catalytic-converter, hyperinflation backtests) - snapshots 0153-0168; wiki updates (glossary, decisions, index); ADR-0044/0045 - mockups + additional shell screens (Agora, Apps, MainScreen, AssetDetail, ...) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
99 lines
3.3 KiB
JavaScript
99 lines
3.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* chipnet-lib-claim.mjs — open-mint claim via the DeviantWallet library.
|
|
* The library counterpart to chipnet-asm-claim.mjs.
|
|
*
|
|
* Delegates to:
|
|
* wallet.planClaim(intent) → fetches the reservoir, runs D-1, returns a
|
|
* typed ClaimPlan (with fee/backing/change math)
|
|
* wallet.executeClaim(plan) → shell builds the claim tx, audits it, the
|
|
* runtime broadcasts (refusing on drift)
|
|
*
|
|
* Supports the gift-claim pattern: set RECIPIENT to a different wallet to
|
|
* pay from one wallet and land the FT at another.
|
|
*
|
|
* Run: node --import tsx scripts/chipnet-lib-claim.mjs
|
|
* Env: WALLET=a|b|c TOKEN=asm|asm2 AMOUNT=1000 RECIPIENT=a|b|c
|
|
*/
|
|
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { TestNetWallet } from 'mainnet-js';
|
|
import { InMemoryTokenRegistry } from '../src/token/registry.js';
|
|
import { connectWallet, tokenFileToTierA } from '../src/wallet/runtime.js';
|
|
|
|
const ROOT = join(import.meta.dirname, '..');
|
|
const WHICH = (process.env.WALLET ?? 'a').toLowerCase();
|
|
const TOKEN = (process.env.TOKEN ?? 'asm').toLowerCase();
|
|
const AMOUNT = BigInt(process.env.AMOUNT ?? '1000');
|
|
const RECIPIENT_WALLET = (process.env.RECIPIENT ?? WHICH).toLowerCase();
|
|
|
|
const KEYS = {
|
|
a: join(ROOT, '.chipnet-keys.json'),
|
|
b: join(ROOT, '.chipnet-keys-b.json'),
|
|
c: join(ROOT, '.chipnet-keys-c.json'),
|
|
};
|
|
if (!KEYS[WHICH]) throw new Error('WALLET must be a/b/c');
|
|
if (!KEYS[RECIPIENT_WALLET]) throw new Error('RECIPIENT must be a/b/c');
|
|
|
|
const TOKEN_FILES = {
|
|
asm: join(ROOT, 'ChipnetTests', '.chipnet-asm-token.json'),
|
|
asm2: join(ROOT, 'ChipnetTests', '.chipnet-asm2-token.json'),
|
|
};
|
|
if (!TOKEN_FILES[TOKEN]) throw new Error('TOKEN must be asm|asm2');
|
|
|
|
function divider() {
|
|
console.log('='.repeat(72));
|
|
}
|
|
|
|
async function main() {
|
|
const registry = new InMemoryTokenRegistry();
|
|
const token = tokenFileToTierA(JSON.parse(readFileSync(TOKEN_FILES[TOKEN], 'utf8')));
|
|
registry.add(token);
|
|
|
|
const { wif } = JSON.parse(readFileSync(KEYS[WHICH], 'utf8'));
|
|
const payer = await TestNetWallet.fromWIF(wif);
|
|
const { tokenaddr: recipientTokenAddr } = JSON.parse(
|
|
readFileSync(KEYS[RECIPIENT_WALLET], 'utf8'),
|
|
);
|
|
|
|
const wallet = connectWallet({
|
|
registry,
|
|
network: 'chipnet',
|
|
privateKey: payer.privateKey,
|
|
cashaddr: payer.cashaddr,
|
|
tokenAddress: payer.tokenaddr,
|
|
});
|
|
|
|
const plan = await wallet.planClaim({
|
|
tokenId: token.categoryId,
|
|
units: AMOUNT,
|
|
recipientTokenAddress: recipientTokenAddr,
|
|
});
|
|
|
|
divider();
|
|
console.log(
|
|
`Wallet ${WHICH.toUpperCase()} claims ${AMOUNT} ${token.ticker}` +
|
|
(RECIPIENT_WALLET !== WHICH ? ` — GIFT to ${RECIPIENT_WALLET.toUpperCase()}` : ''),
|
|
);
|
|
divider();
|
|
console.log(plan.confirmationMessage);
|
|
if (plan.warnings.length) {
|
|
console.log('');
|
|
for (const w of plan.warnings) console.log(` [${w.severity}] ${w.message}`);
|
|
}
|
|
divider();
|
|
|
|
if (plan.verification === 'non-canonical') {
|
|
throw new Error('Refusing to claim: token is at a non-canonical contract.');
|
|
}
|
|
|
|
const { txid } = await wallet.executeClaim(plan);
|
|
console.log('');
|
|
console.log(`Claim TXID: ${txid}`);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error('FAILED:', err?.message ?? err);
|
|
if (err?.stack) console.error(err.stack);
|
|
process.exit(1);
|
|
});
|