Some checks failed
deploy / deploy (push) Failing after 1m35s
Proof: first non-mocked tradeable loop for one pair using funded NEAR Intents inventory, Kafka, and PostgreSQL. Assumptions: solver-side execution is performed by signed token_diff quote responses over the Solver Relay; EURe is treated as 1:1 with EUR; k3s runtime uses unrip-dev.near as the named signer account. Still fake: signer key is not yet registered on intents.near, strategy and executor remain disarmed by default, and no live mainnet quote response has been submitted from this repo yet.
44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { KeyPair } from 'near-api-js';
|
|
|
|
import { buildIntentNonce, buildQuoteResponseSubmission } from '../src/venues/near-intents/signing.mjs';
|
|
|
|
test('intent nonce uses verifier salt prefix and 32 byte base64 payload', () => {
|
|
const nonce = buildIntentNonce('252812b3');
|
|
const decoded = Buffer.from(nonce, 'base64');
|
|
|
|
assert.equal(decoded.length, 32);
|
|
assert.equal(decoded.subarray(0, 4).toString('hex'), '252812b3');
|
|
});
|
|
|
|
test('quote response signing builds token_diff payload for solver submission', () => {
|
|
const signer = KeyPair.fromRandom('ed25519');
|
|
const submission = buildQuoteResponseSubmission({
|
|
command: {
|
|
quote_id: 'quote-1',
|
|
asset_in: 'nep141:btc.omft.near',
|
|
asset_out: 'nep141:eure.omft.near',
|
|
request_kind: 'exact_in',
|
|
amount_in: '5000',
|
|
amount_out: null,
|
|
min_deadline_ms: '60000',
|
|
quote_output: {
|
|
amount_out: '4900000000000000000',
|
|
},
|
|
},
|
|
signerAccountId: 'solver.near',
|
|
signer,
|
|
verifierContract: 'intents.near',
|
|
currentSaltHex: '252812b3',
|
|
now: Date.parse('2026-04-02T10:00:00.000Z'),
|
|
});
|
|
|
|
assert.equal(submission.quote_id, 'quote-1');
|
|
assert.equal(submission.signed_data.standard, 'raw_ed25519');
|
|
const payload = JSON.parse(submission.signed_data.payload);
|
|
assert.equal(payload.signer_id, 'solver.near');
|
|
assert.equal(payload.intents[0].diff['nep141:btc.omft.near'], '5000');
|
|
assert.equal(payload.intents[0].diff['nep141:eure.omft.near'], '-4900000000000000000');
|
|
});
|