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

Add a SorobanRpc.Server.getWasm(contractId) method #961

Closed
Shaptic opened this issue May 8, 2024 · 1 comment
Closed

Add a SorobanRpc.Server.getWasm(contractId) method #961

Shaptic opened this issue May 8, 2024 · 1 comment

Comments

@Shaptic
Copy link
Contributor

Shaptic commented May 8, 2024

Is your feature request related to a problem? Please describe.
Building ledger entries by hand sucks and you need to understand too much about Soroban internals.

Describe the solution you'd like
See title, add a method to the server:

class Server {
  // ...
  getWasm(contractId: string): Promise<Buffer>;
}

which will make the correct underlying getLedgerEntries call for you.

Describe alternatives you've considered
Doing it manually:

const contractLedgerKey = new Contract(contractId).getFootprint();
const response = await server.getLedgerEntries(contractLedgerKey);
const wasmHash = response.entries[0].val.contractData().val().contractInstance().executable().wasmHash();
const ledgerKeyWasmHash = xdr.LedgerKey.contractCode(new xdr.LedgerKeyContractCode({ hash: wasmHash }));
const responseWasm = await server.getLedgerEntries(ledgerKeyWasmHash);
return responseWasm.entries[0].val.contractCode().code();

This is gross.

Additional context
See stellar-sdk#960, a review comment from @willemneal.

This is documented in the API reference for getLedgerEntries, but it'd still be better to make it built in.

@Shaptic
Copy link
Contributor Author

Shaptic commented May 23, 2024

Closed by #960

@Shaptic Shaptic closed this as completed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant