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>
91 lines
2.9 KiB
JavaScript
91 lines
2.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* chipnet-lib-send.mjs — peer-to-peer ASM transfer via the DeviantWallet
|
|
* library. The library counterpart to chipnet-asm-send.mjs.
|
|
*
|
|
* Instead of hand-building the TransactionBuilder, this delegates to:
|
|
* wallet.planTierASend(intent) → typed, validated TierASendPlan
|
|
* wallet.executeTierASend(plan) → shell builds + audits + broadcasts
|
|
*
|
|
* The two-phase split mirrors the production UI: plan first (show the
|
|
* confirmation + warnings), then execute on consent.
|
|
*
|
|
* Run: node --import tsx scripts/chipnet-lib-send.mjs
|
|
* Env: FROM=a|b|c TO=a|b|c AMOUNT=100
|
|
*/
|
|
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 ASM_FILE = join(ROOT, 'ChipnetTests', '.chipnet-asm-token.json');
|
|
|
|
const FROM = (process.env.FROM ?? 'a').toLowerCase();
|
|
const TO = (process.env.TO ?? 'b').toLowerCase();
|
|
const AMOUNT = BigInt(process.env.AMOUNT ?? '100');
|
|
|
|
const KEYS = {
|
|
a: join(ROOT, '.chipnet-keys.json'),
|
|
b: join(ROOT, '.chipnet-keys-b.json'),
|
|
c: join(ROOT, '.chipnet-keys-c.json'),
|
|
};
|
|
if (!KEYS[FROM]) throw new Error('FROM must be a/b/c');
|
|
if (!KEYS[TO]) throw new Error('TO must be a/b/c');
|
|
|
|
function divider() {
|
|
console.log('='.repeat(72));
|
|
}
|
|
|
|
async function main() {
|
|
const asmFile = JSON.parse(readFileSync(ASM_FILE, 'utf8'));
|
|
const registry = new InMemoryTokenRegistry();
|
|
const asm = tokenFileToTierA(asmFile);
|
|
registry.add(asm);
|
|
|
|
const { wif: wifFrom } = JSON.parse(readFileSync(KEYS[FROM], 'utf8'));
|
|
const { tokenaddr: toTokenaddr } = JSON.parse(readFileSync(KEYS[TO], 'utf8'));
|
|
|
|
const sender = await TestNetWallet.fromWIF(wifFrom);
|
|
const wallet = connectWallet({
|
|
registry,
|
|
network: 'chipnet',
|
|
privateKey: sender.privateKey,
|
|
cashaddr: sender.cashaddr,
|
|
tokenAddress: sender.tokenaddr,
|
|
});
|
|
|
|
// Phase 1: plan.
|
|
const plan = await wallet.planTierASend({
|
|
tokenId: asm.categoryId,
|
|
units: AMOUNT,
|
|
recipientTokenAddress: toTokenaddr,
|
|
});
|
|
|
|
divider();
|
|
console.log(`Wallet ${FROM.toUpperCase()} → ${TO.toUpperCase()}: ${AMOUNT} ${asm.ticker}`);
|
|
divider();
|
|
console.log(plan.confirmationMessage);
|
|
if (plan.warnings.length) {
|
|
console.log('');
|
|
for (const w of plan.warnings) console.log(` [${w.severity}] ${w.message}`);
|
|
}
|
|
divider();
|
|
|
|
// Refuse non-canonical sends by default (the shell would also refuse).
|
|
if (plan.verification === 'non-canonical') {
|
|
throw new Error('Refusing to send: token is at a non-canonical contract.');
|
|
}
|
|
|
|
// Phase 2: execute.
|
|
const { txid } = await wallet.executeTierASend(plan);
|
|
console.log('');
|
|
console.log(`Transfer TXID: ${txid}`);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error('FAILED:', err?.message ?? err);
|
|
if (err?.stack) console.error(err.stack);
|
|
process.exit(1);
|
|
});
|