Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to include the contract code footprint, as that is always needed #557

Merged
merged 2 commits into from
Nov 3, 2022
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stellar-base",
"version": "8.0.1-soroban.3",
"version": "8.0.1-soroban.4",
"description": "Low level stellar support library",
"main": "./lib/index.js",
"types": "./types/index.d.ts",
Expand Down
10 changes: 9 additions & 1 deletion src/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ export class Contract {
...params
],
// TODO: Figure out how to calculate this or get it from the user?
footprint: new xdr.LedgerFootprint({ readOnly: [], readWrite: [] })
footprint: new xdr.LedgerFootprint({
readOnly: [
new xdr.LedgerKeyContractData({
contractId: this._id,
key: xdr.ScVal.scvStatic(xdr.ScStatic.scsLedgerKeyContractCode())
})
],
readWrite: []
})
});
}
}
19 changes: 19 additions & 0 deletions test/unit/contract_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
describe('Contract.call', function() {
it('includes the contract code footprint', function() {
let contractId = '00000000000000000000000000000001';
let contract = new StellarBase.Contract(contractId);
let call = contract.call('foo');
let op = call.body().invokeHostFunctionOp();
let readOnly = op.footprint().readOnly();
expect(readOnly.length).to.equal(1);
let expected = new StellarBase.xdr.LedgerKeyContractData({
contractId,
key: StellarBase.xdr.ScVal.scvStatic(
StellarBase.xdr.ScStatic.scsLedgerKeyContractCode()
)
})
.toXDR()
.toString('base64');
expect(readOnly[0].toXDR().toString('base64')).to.equal(expected);
});
});