Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crypto/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ node_modules/
coverage/
.nyc_output/
.wallet/
devnet/local/
*.vault.local.json
*.wallet.local.json
19 changes: 19 additions & 0 deletions crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,32 @@
"validate:product-transactions": "node src/validate-product-testnet-fixtures.js",
"wallet:product-smoke": "node src/validate-product-testnet-fixtures.js",
"wallet:create": "node src/wallet-cli.js create",
"wallet:import": "node src/wallet-cli.js import",
"wallet:check": "node src/wallet-cli.js check",
"wallet:unlock": "node src/wallet-cli.js unlock",
"wallet:lock": "node src/wallet-cli.js lock",
"wallet:list": "node src/wallet-cli.js list",
"wallet:metadata": "node src/wallet-cli.js metadata",
"wallet:export-metadata": "node src/wallet-cli.js export-metadata",
"wallet:verify-metadata": "node src/wallet-cli.js verify-metadata",
"wallet:add-account": "node src/wallet-cli.js add-account",
"wallet:rotate": "node src/wallet-cli.js rotate",
"wallet:sign": "node src/wallet-cli.js sign",
"wallet:sign-transfer": "node src/wallet-cli.js sign-transfer",
"wallet:sign-token-launch": "node src/wallet-cli.js sign-token-launch",
"wallet:sign-token-transfer": "node src/wallet-cli.js sign-token-transfer",
"wallet:sign-pool-create": "node src/wallet-cli.js sign-pool-create",
"wallet:sign-add-liquidity": "node src/wallet-cli.js sign-add-liquidity",
"wallet:sign-remove-liquidity": "node src/wallet-cli.js sign-remove-liquidity",
"wallet:sign-swap": "node src/wallet-cli.js sign-swap",
"wallet:sign-withdrawal-intent": "node src/wallet-cli.js sign-withdrawal-intent",
"wallet:sign-finality": "node src/wallet-cli.js sign-finality",
"wallet:verify": "node src/wallet-cli.js verify",
"wallet:submit": "node src/wallet-cli.js submit",
"wallet:query": "node src/wallet-cli.js query",
"wallet:e2e": "node src/wallet-e2e.js",
"wallet:transfer:e2e": "node src/wallet-e2e.js --transfer-only",
"wallet:operator-bridge": "node src/operator-bridge-cli.js",
"wallet:pilot-config": "node src/pilot-wallet-cli.js config-from-env",
"wallet:pilot-metadata": "node src/pilot-wallet-cli.js metadata",
"wallet:pilot-sign": "node src/pilot-wallet-cli.js sign",
Expand Down
71 changes: 71 additions & 0 deletions crypto/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,19 @@ export interface LocalAlphaEnvelopeValidationResult {
errors: string[];
}

export interface WalletEnvelopeVerificationResult {
schema: "flowchain.wallet_envelope_verification.v0";
valid: boolean;
signatureValid: boolean;
chainIdMatch: boolean;
signerDerivedAddress: Bytes32 | null;
payloadHash: Bytes32 | null;
transactionId: Bytes32 | null;
replayKey: string | null;
rejectionReason: string | null;
errors: string[];
}

export const ZERO_BYTES32: Bytes32;
export const FLOWPULSE_SCHEMA_ID_PREIMAGE: string;
export const FLOWPULSE_EVENT_SIGNATURE: string;
Expand All @@ -570,6 +583,12 @@ export const LOCAL_ALPHA_FINALITY_STATES: Readonly<Record<string, number>>;
export const LOCAL_ALPHA_HARDWARE_TRANSPORTS: Readonly<Record<string, number>>;
export const LOCAL_ALPHA_SIGNER_ROLES: Readonly<Record<string, number>>;
export const LOCAL_ALPHA_BRIDGE_STATUSES: Readonly<Record<string, number>>;
export const LOCAL_WALLET_PUBLIC_METADATA_SCHEMA: string;
export const LOCAL_WALLET_KEY_SCHEME: string;
export const DEFAULT_LOCAL_WALLET_CHAIN_ID: string;
export const LOCAL_TEST_UNIT_ASSET_ID: Bytes32;
export const WALLET_SIGNED_ENVELOPE_SCHEMA: string;
export const WALLET_ENVELOPE_VERIFICATION_SCHEMA: string;

export function strip0x(value: string): string;
export function bytesToHex(bytes: Uint8Array): Hex;
Expand Down Expand Up @@ -721,13 +740,30 @@ export function createEncryptedTestVault(input?: {
signerRole?: string;
createdAtUnixMs?: number | bigint | string;
privateKey?: Hex;
chainId?: number | bigint | string;
lastKnownNonce?: number | bigint | string;
}): Record<string, unknown>;
export function unlockEncryptedTestVault(input: {
vault: Record<string, unknown>;
password: string;
}): Record<string, unknown>;
export function listVaultPublicAccounts(vaultOrSession: Record<string, unknown>): Array<Record<string, unknown>>;
export function exportVaultPublicMetadata(vaultOrSession: Record<string, unknown>): Record<string, unknown>;
export function exportLocalWalletPublicMetadata(
vaultOrSession: Record<string, unknown>,
input?: { updatedAtUnixMs?: number | bigint | string }
): Record<string, unknown>;
export function validateLocalWalletPublicMetadata(
metadata: Record<string, unknown>,
context?: { expectedChainId?: number | bigint | string }
): {
schema: string;
valid: boolean;
secretFree: boolean;
chainIdMatch: boolean;
accountCount: number;
errors: string[];
};
export function addEncryptedTestVaultAccount(input: {
vault: Record<string, unknown>;
password: string;
Expand All @@ -736,6 +772,8 @@ export function addEncryptedTestVaultAccount(input: {
createdAtUnixMs?: number | bigint | string;
privateKey?: Hex;
signerId?: Bytes32;
chainId?: number | bigint | string;
lastKnownNonce?: number | bigint | string;
}): Record<string, unknown>;
export function rotateEncryptedTestVaultAccount(input: {
vault: Record<string, unknown>;
Expand All @@ -744,6 +782,7 @@ export function rotateEncryptedTestVaultAccount(input: {
label?: string;
createdAtUnixMs?: number | bigint | string;
privateKey?: Hex;
chainId?: number | bigint | string;
}): Record<string, unknown>;
export function signLocalTransactionWithVault(input: {
vault: Record<string, unknown>;
Expand All @@ -760,6 +799,38 @@ export function verifyLocalTransactionSignature(input: {
context?: Record<string, unknown>;
}): LocalAlphaEnvelopeValidationResult;

export function buildProductTransferDocument(input: Record<string, unknown>): Record<string, unknown>;
export function buildProductTokenLaunchDocument(input: Record<string, unknown>): Record<string, unknown>;
export function buildProductPoolCreateDocument(input: Record<string, unknown>): Record<string, unknown>;
export function buildProductAddLiquidityDocument(input: Record<string, unknown>): Record<string, unknown>;
export function buildProductRemoveLiquidityDocument(input: Record<string, unknown>): Record<string, unknown>;
export function buildProductSwapDocument(input: Record<string, unknown>): Record<string, unknown>;
export function buildBridgeWithdrawalIntentDocument(input: Record<string, unknown>): Record<string, unknown>;
export function buildFinalityActionDocument(input: Record<string, unknown>): Record<string, unknown>;
export function signWalletDocumentWithVault(input: {
vault: Record<string, unknown>;
password: string;
signerKeyId: Bytes32;
document: Record<string, unknown>;
chainId: number | bigint | string;
nonce: number | bigint | string;
issuedAtUnixMs?: number | bigint | string;
fee?: Record<string, unknown> | null;
expiresAtUnixMs?: number | bigint | string | null;
}): Promise<Record<string, unknown>>;
export function verifyWalletSignedEnvelope(input: {
envelope: Record<string, unknown>;
context?: {
document?: Record<string, unknown>;
chainId?: number | bigint | string;
expectedNonce?: number | bigint | string;
expectedSignerId?: Bytes32;
expectedSignerAddress?: Bytes32;
expectedPayloadType?: string;
seenNonces?: Set<string>;
};
}): WalletEnvelopeVerificationResult;

export const PILOT_MESSAGE_SCHEMAS: readonly string[];
export function validatePilotOperatorEnvelope(input: {
document: Record<string, unknown>;
Expand Down
2 changes: 2 additions & 0 deletions crypto/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export * from "./pilot-envelope-validation.js";
export * from "./pilot-operator.js";
export * from "./transactions.js";
export * from "./wallet.js";
export * from "./wallet-documents.js";
export * from "./wallet-envelope.js";
Loading
Loading