Repository navigation
Add Go examples to the archival, conventions, rpc, conversions and events guides - #3124
Conversation
|
🤖 Automated message from the Stellar Triage Bot. Reviewing my own PR, which the issue lane opened for #1770. Verified: every Go symbol matches go-stellar-sdk v0.9.0 (newest) and GORM v1.31.2. Not run: the Go blocks on all 14 pages, which a maintainer runs before merge. Merge #3115, then #3123, then this PR. Ready to merge. What I checked
|
ElliotFriend
left a comment
There was a problem hiding this comment.
Every Go block compiles against go-stellar-sdk v0.9.0, passes go vet, and ran on testnet. Conversion outputs match the JavaScript tab exactly. A few fixes before merge:
Code
events/consume.mdx:322:var events []StellarEventredeclareseventsfrom:203when the blocks share onemain(events redeclared in this block). Rename it (for exampleallEvents). The JavaScript tab has the same clash withconst events, so fix it there too.conventions/deploy-sac-with-code.mdx:148: following the comment doesn't compile either way. In a separate file therpcclientimport is unused; pasted into this file, it needserrorsandtime. Say which imports to adjust.conversions/string-conversions.mdx:75: the fragment callslog.Fatalbut doesn't importlog.- Each page's
prepareTransactionasserts one operation type and panics on any other. Add a one-line comment saying so.
Prose and comments
- Oxford comma:
extend-persistent-entry.mdx:36,:203;deploy-sac-with-code.mdx:513;extending-wasm-ttl.mdx:354,:436;address-conversions.mdx:12;events/ingest.mdx:10; and theprepareTransactiondoc comment on every page.
|
🤖 Automated message from the Stellar Triage Bot. Back on this because @ElliotFriend requested changes. Pushed What I checked
|
…imports, note the single-operation helpers, Oxford commas
64bf325 to
6a6c092
Compare
|
🤖 Automated message from the Stellar Triage Bot. Back on this because GitHub rebased the stack after #3115 merged. The rebase changed no content: all three commits match What I checked
|
ElliotFriend
left a comment
There was a problem hiding this comment.
Thanks! Every point from my review is fixed.
events/consume.mdx: withallEvents, the Go blocks now build and passgo vetin onemain, with nothing extra added.deploy-sac-with-code.mdx:148: the comment now names the right lines (rpcServerandserver) and the imports to adjust.string-conversions.mdx: the fragment importslog.- The single-operation notes and the Oxford commas look good.
🤖 Automated message from the Stellar Triage Bot.
Refs #1770
Working this because @ElliotFriend approved the Go and Java splits in #1770 and asked me to keep building the stack. This is Go B: Go tabs on the other 14
build/guidespages. Base: #3123 (docs-agent/1770-go-a). Go C, Go D and Java A to D follow.What changed
archival/:create-restoration-footprint,extend-persistent-entry,restore-contract,restore-dataconventions/:deploy-sac-with-code,extending-wasm-ttlrpc/:generate-ledger-keys,retrieve-contract-codeconversions/:address-conversions,bytes-conversions,scval-conversions,string-conversionsevents/:consume,ingestbytes-conversionsandstring-conversions: Rust moved from first to last.ingest: JavaScript moved before Python.prepareTransaction. Where a page needs one, the Go tab defines a small helper and says so in one line.restore-datadefinesassembleTransactionfor the same reason.restore-contractandrestore-datareuse the GosubmitTxfromsubmit-transaction-wait(Add Go examples to the transactions and basics guides #3123).A choice to confirm
gorm.io/driver/sqlite, the Go match for Prisma and SQLAlchemy. That driver needs cgo. Tell me if you preferdatabase/sqlinstead.storeEventsskips events already stored (OnConflict{DoNothing: true}). Each run starts again at the latest ingested ledger, so that ledger's events come back.Skipped
dapps/state-archival: browser code only, as agreed in Standardize on the languages of the examples throughout the Guides section #1770.BytesN to Fixed-Size Array, the contract TTL code) and the CLI tab.Why this matters
Go readers had no example on these 14 pages. @ElliotFriend chose all four languages on every page in #1770.
Sweep
Not a claim fix, so no sweep. I checked the prose next to each new tab for text that named only JavaScript or Python, and updated it.
Verified
clients/rpcclient/main.go,protocols/rpc/{get_events,get_ledger_entries,simulate_transaction,send_transaction,get_transaction,get_fee_stats,get_health}.go,txnbuild/{transaction,extend_footprint_ttl,restore_footprint,invoke_host_function,asset}.go,xdr/{xdr_generated,ledger_key,scval,account_id}.go,strkey/main.go. The pages pin no Go SDK version.txnbuild.NewTransactionaddsSorobanData.ResourceFeeto the fee (transaction.go:902-926). Sorestore-datadoes not addminResourceFeeby hand, unlike the JavaScript tab.xdr.ScVal.String()prints a symbol as its text, an address as its strkey and ani32as a number (scval.go:249-327). That gives the listener output onconsume.SegmentFilter.UnmarshalJSONtakes*or a base64 ScVal (get_events.go:386-404), soingestdecodes the topic filter from the same JSON as the other tabs.AfterCreate(*gorm.DB) errorhook (callbacks/interfaces.go:9),clause.OnConflict.DoNothing,logger.LogMode.gorm.io/driver/sqlitev1.6.0 importsmattn/go-sqlite3(cgo).pnpm checkpasses: prettier,mint validate, no broken links.Not verified
goneeds approval in this lane. A maintainer runs the Go blocks before merge, as @ElliotFriend said on Add Go examples to the transactions and basics guides #3123.main(stacked PR).Overlaps
consume,ingestand the archival pages (🎨 Clean up images, imports #2231, 📝 Refresh six classic guides #723). Neither adds Go.Found in passing, not fixed here
Defects in existing code on these pages. #3119 collects such defects, but it carries
bot:hands-off, so I did not post there. A maintainer can move these to it.conversions/bytes-conversions.mdxL23 and L26 (JavaScript):const addressFromBytesis declared twice in one block, aSyntaxError.events/ingest.mdx(JavaScript):latestEventIngestedisnullon an empty database, so.ledgerthrows.forEach(async ...)does not wait for the writes.event.contractId!is TypeScript syntax in ajavascriptblock.events/ingest.mdxL238 (Python): usescontract_idbefore L251 defines it.