|
7 | 7 | namespace stellar
|
8 | 8 | {
|
9 | 9 |
|
| 10 | +std::pair<TransactionEnvelope, LedgerKey> |
| 11 | +getWasmRestoreTx(PublicKey const& publicKey, SequenceNumber seqNum) |
| 12 | +{ |
| 13 | + TransactionEnvelope txEnv; |
| 14 | + txEnv.type(ENVELOPE_TYPE_TX); |
| 15 | + |
| 16 | + auto& tx = txEnv.v1().tx; |
| 17 | + tx.sourceAccount = toMuxedAccount(publicKey); |
| 18 | + tx.fee = 100'000'000; |
| 19 | + tx.seqNum = seqNum; |
| 20 | + |
| 21 | + Preconditions cond; |
| 22 | + cond.type(PRECOND_NONE); |
| 23 | + tx.cond = cond; |
| 24 | + |
| 25 | + Memo memo; |
| 26 | + memo.type(MEMO_NONE); |
| 27 | + tx.memo = memo; |
| 28 | + |
| 29 | + Operation restoreOp; |
| 30 | + restoreOp.body.type(RESTORE_FOOTPRINT); |
| 31 | + |
| 32 | + tx.operations.emplace_back(restoreOp); |
| 33 | + |
| 34 | + auto const writeByteWasm = rust_bridge::get_write_bytes(); |
| 35 | + std::vector<uint8_t> wasm(writeByteWasm.data.begin(), |
| 36 | + writeByteWasm.data.end()); |
| 37 | + |
| 38 | + LedgerKey contractCodeLedgerKey; |
| 39 | + contractCodeLedgerKey.type(CONTRACT_CODE); |
| 40 | + contractCodeLedgerKey.contractCode().hash = sha256(wasm); |
| 41 | + |
| 42 | + SorobanResources restoreResources; |
| 43 | + restoreResources.footprint.readWrite = {contractCodeLedgerKey}; |
| 44 | + restoreResources.instructions = 0; |
| 45 | + restoreResources.readBytes = 2000; |
| 46 | + restoreResources.writeBytes = 2000; |
| 47 | + |
| 48 | + tx.ext.v(1); |
| 49 | + tx.ext.sorobanData().resources = restoreResources; |
| 50 | + tx.ext.sorobanData().resourceFee = 55'000'000; |
| 51 | + |
| 52 | + return {txEnv, contractCodeLedgerKey}; |
| 53 | +} |
| 54 | + |
10 | 55 | std::pair<TransactionEnvelope, LedgerKey>
|
11 | 56 | getUploadTx(PublicKey const& publicKey, SequenceNumber seqNum)
|
12 | 57 | {
|
|
0 commit comments