stellar / js-stellar-sdk

Main Stellar client library for the JavaScript language.
https://stellar.github.io/js-stellar-sdk/
Apache License 2.0
615 stars 296 forks source link

add a from method to ContractClient to instantiate from a contractId #960

Closed BlaineHeffron closed 1 month ago

BlaineHeffron commented 2 months ago

Adds a from method which uses the contractId to create an instance of the ContractClient by retrieving the wasm from the blockchain and extracting its ContractSpec. I also add a fromWasm method which bypasses the wasm retrieval portion if you already have the wasm buffer.

chadoh commented 1 month ago

Still marked as draft. Is that intended, @BlaineHeffron? Seems like it's about ready to go!

BlaineHeffron commented 1 month ago

Still marked as draft. Is that intended, @BlaineHeffron? Seems like it's about ready to go!

See my comment here - https://github.com/stellar/js-stellar-sdk/pull/960#discussion_r1595553929

To summarize, I think it makes sense since we are giving a way to create it from a wasm we should also give a way to create it from a wasmHash. This would also make sense in the context of our e2e tests.

BlaineHeffron commented 1 month ago

Should be all ready to go now.

BlaineHeffron commented 1 month ago

Latest commit fixes all of Chad's comments.

chadoh commented 1 month ago

Tests are failing

BlaineHeffron commented 1 month ago

Tests are failing

Looks like that weird spawnSync issue we were seeing before. I added a fallback in case it doesnt work the first time.

chadoh commented 1 month ago

ok, I guess I just don't have the correct permissions to get this thing marked as mergeable

BlaineHeffron commented 1 month ago

I addressed comments from @Shaptic although this now is dependent on https://github.com/stellar/js-stellar-base/pull/744 being merged first. The latest changes remove the external js-xdr dependency and uses the ceareal namespace from stellar-base for XdrReader.

socket-security[bot] commented 1 month ago

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@stellar/stellar-base@12.0.0-rc.1 None +3 711 kB

🚮 Removed packages: npm/@stellar/stellar-base@11.1.0

View full report↗︎