Repository navigation
A typed client for Token Standard registries, and a check on the contracts they hand you #129
monsieurleberre
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Before you submit a Token Standard transfer or settlement, you call the registry's off-ledger HTTP API, and it answers with a choice context that includes disclosed contracts. 0.8.0 adds two things for that moment.
Splice.Api.Token.Registry.Clientis a typed client for that API, generated with Refitter from the OpenAPI specs of the pinned Splice release, one namespace per spec (token metadata, transfer instruction, allocation, allocation instruction).AddSpliceTokenRegistryClientsregisters one Refit interface per API, such asIAllocationV2Api, over one namedHttpClientwhose base address is the registry's.ToDisclosedContract()turns the disclosed contracts of an allocation V2 or allocation instruction V2 choice context into the SDK'sDisclosedContractfor your submission. The package is versioned after its Splice release (0.10.0.21), like theSplice.*bindings.CreatedEventBlob.Decode(inCanton.Ledger.Kernel) reads a disclosed contract'screatedEventBlob, so you can check who signed it before you use it. It returns aDecodedCreatedEventBlobwith the package name, template id,Signatories(key maintainers included),ObserversandCreatedAt:ReadContract<T>()goes one step further and decodes a generated template into aContract<T>, matching by package name, module and entity so a contract created under an upgraded package version still reads. A malformed blob throwsMalformedResponseException.Docs: the registry client and Kernel READMEs.
Tell us how it went and anything you'd improve. Bugs are easiest to track as issues.
All reactions