WIP refactor: replace @novasamatech with @parity/truapi#186
Draft
valentinfernandez1 wants to merge 10 commits into
Draft
WIP refactor: replace @novasamatech with @parity/truapi#186valentinfernandez1 wants to merge 10 commits into
valentinfernandez1 wants to merge 10 commits into
Conversation
…rity/truapi Replace the third-party @novasamatech/host-api-wrapper with the in-house @parity/truapi client across the low-level host-API surface, the statement store, and preimage lookups; drop @novasamatech/sdk-statement from @parity/product-sdk-statement-store. - Add a sandbox-bootstrap module (packages/host/src/transport.ts) that detects the host environment (iframe / webview / injected port), builds the truapi transport, creates the client and runs system.handshake — replacing the wrapper's auto-detected hostApi singleton. - Migrate getTruApi, permissions, entropy, resource allocation, host localStorage, the statement store (createProofAuthorized) and preimage onto the truapi domain clients. Statement value types derive from the truapi wire types so protocol changes propagate automatically. - getHostProvider (PAPI JsonRpcProvider), accounts, theme, chat and payments remain on the wrapper for now (marked TODO); behavior is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the third-party
@novasamatech/host-api-wrapper(plushost-apiandsdk-statement) with our in-house@parity/truapiclient. The whole host-API surface now goes through truapi; neither@parity/product-sdk-hostnor@parity/product-sdk-signerimports the wrapper at runtime anymore.What moved to
@parity/truapigetTruApi,requestPermission/requestDevicePermission,deriveEntropy,requestResourceAllocation, hostlocalStorage,isInsideContainer.getStatementStore,createProofAuthorized(the RFC-10 sponsored path),subscribe/submit.@parity/product-sdk-statement-storeno longer depends on@novasamatech/sdk-statement, and its statement types are derived from the truapi wire types now, so protocol changes flow through automatically.getPreimageManager/createHostPreimageManager.getThemeProvider,getChatManager,getPaymentManager.getHostProvider, the PAPIJsonRpcProvider. This one is a backport of the wrapper'screatePapiProviderinto a newpapi-providermodule, rebuilt onchain.*+system.featureSupported.getAccountsProvider, a newaccountsmodule (backport ofcreateAccountsProvider) onaccount.*+signing.*, including the PAPIPolkadotSignerfactories. The signer'sHostProvidernow just consumeshost'sgetAccountsProviderand asks forChainSubmitthroughhost'srequestPermission, instead of importing the wrapper itself.Dependencies
Removed
@novasamatech/host-api,host-api-wrapper, andsdk-statementeverywhere they were declared:host,signer, the example demos, the catalog, and thetsupexternal lists.@parity/truapiis now a hard dependency ofhost, along with@polkadot-api/json-rpc-provider(for the PAPI provider) and@polkadot-api/substrate-bindings(the signer needs it to decode metadata).@parity/product-sdk-terminalis out of scope here. It depends on a different@novasamatechfamily (host-papp/statement-store/storage-adapter) that has nothing to do with the host-api wrapper.Breaking change: the
getTruApi()client shapeIf you only use the high-level helpers (
getStatementStore,getPaymentManager,getThemeProvider,getChatManager,getHostProvider,getAccountsProvider,requestPermission, …), nothing changes for you.The raw client from
getTruApi()is a different story. It went from the flat, versioned wrapper shape to truapi's namespaced client. Four things change at basically every call site:truApi.devicePermission(…)becomestruApi.permissions.requestDevicePermission(…).{ tag: "v1", value }envelope is gone. Pass the request straight in; truapi handles versioning internally.res.value. An account id is{ dotNsIdentifier, derivationIndex }(not[dotNs, idx]), a chain is{ genesisHash }, raw bytes are{ bytes: "0x…" }, and responses readres.granted/res.supported/res.signature/res.outcomes.GenericErroris{ reason }and tagged errors are{ tag, value? }(previously{ value: { name, … } }).A few smaller ones worth calling out:
ChatMessageContent'sTextvariant wraps its string as{ text }now, chat custom-message rendering is gone (truapi has no equivalent yet), and host-mode statement submission uses the RFC-10 sponsored path.The full cheat-sheet and worked examples are in the guide: Migrating to
@parity/truapi.Validation
I tested this against host-playground, which has a harness in
src/lib/tests.tswith one entry per host-API method. Each one calls the real method against the SDK inside a live host container and checks the result.What I did:
host,signer, andchain-clientpackages into host-playground.getTruApi()call intests.tsto the new shapes (the same changes the guide describes: domain methods, no{ tag: "v1" }envelopes, object account ids,{ bytes }payloads, the new response and error fields).