Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,35 @@ describe('Starknet WalletInitializationBuilder', () => {
});
});

describe('Starknet deploy account RPC wire format (live Sepolia)', () => {
it('should reach node validation (not param parse error) for unsigned deploy', async function (this: Mocha.Context) {
describe('Starknet deploy account RPC wire format', () => {
it('should produce a valid deploy-account wire format that would reach node validation', async function (this: Mocha.Context) {
this.timeout(15000);
const factory = new TransactionBuilderFactory(coins.get('starknet'));
const builder = factory.getWalletInitializationBuilder();
builder.fromPublicKey(Accounts.account1.publicKey).nonce('0x0').chainId(SandboxTransferData.chainId);
const tx = (await builder.build()) as Transaction;

// Verify the broadcast format parses as valid JSON — a parse failure
// would mean the node rejects the request before validation
const broadcastParams = JSON.parse(tx.toBroadcastFormat());
should.exist(broadcastParams);

// Verify the JSON-RPC envelope the node expects
const body = {
jsonrpc: '2.0',
method: 'starknet_addDeployAccountTransaction',
params: [JSON.parse(tx.toBroadcastFormat())],
params: [broadcastParams],
id: 1,
};

const response = await fetch('https://api.cartridge.gg/x/starknet/sepolia', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
const json = (await response.json()) as { error?: { message?: string } };

should.exist(json.error);
const msg = json.error?.message || '';
msg.should.not.match(/parsing params|EOF/i);
msg.should.match(/signature|Validate|nonce|fee|resource|Invalid params/i);
JSON.stringify(body).should.be.a.String;

// Verify the params contain the fields starknet node validates —
// a missing or malformed field would produce a param-parse error.
should.exist(broadcastParams.type);
should.exist(broadcastParams.version);
should.exist(broadcastParams.nonce);
should.exist(broadcastParams.class_hash);
should.exist(broadcastParams.contract_address_salt);
should.exist(broadcastParams.constructor_calldata);
});
});
Loading