You can do following to allow passing blob into contract without a lot of overhead:
export function setContractToDeploy(): void {
env.input(0);
util.read_register(0);
// ...
}
see: https://github.com/near/near-sdk-as/blob/9b0526c5cb0ea964cf3fa2983c37fba01aaed7c1/assembly/runtime/util.ts#L82 https://github.com/near/near-sdk-as/blob/72464cdfec7ab373b138a6fc3218f6b3a4147edf/assembly/runtime/env/env.ts#L41
Then on the near-api-js
side you can do smth like:
const { functionCall } = nearApi.transaction;
await account.signAndSendTransaction(contractId, [functionCall('setContractToDeploy', bufferWithContract)]);