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

Implement IAlgodClient using dotnet SDK #157

Closed
jasonboukheir opened this issue Nov 1, 2022 · 1 comment
Closed

Implement IAlgodClient using dotnet SDK #157

jasonboukheir opened this issue Nov 1, 2022 · 1 comment
Assignees

Comments

@jasonboukheir
Copy link
Member

jasonboukheir commented Nov 1, 2022

One issue in the implementation is that IAlgodClient returns AlgoApiRequest<*>.Sent types for building out IProgress and CancellationToken parameters, while the dotnet SDK returns basic Task<*> types.

The AlgoApiRequest<*>.Sent needs a UnityWebRequest to build. Since we're already overriding the HttpMessageHandler to use UnityWebRequest, we can use the sent UnityWebRequest to recreate an AlgoApiRequest<*>.Sent and return that instead. Unfortunately, the only way to do this is to set a reference of the last sent UnityWebRequest.

If we want to allow multithreading, then this will require a lock statement on the overridden HttpMessageHandler.

Here's the plan:

  1. Implement HttpMessageHandler using UnityWebRequest, and expose a LastSentRequest property that is set whenever SendAsync is called. Call this UnityHttpMessageHandler.
  2. Construct the dotnet SDK API classes using UnityHttpMessageHandler.
  3. When calling any of the dotnet SDK API endpoints, call lock(unityHttpMessageHandler) to prevent other threads from accessing it. The lock will release once the http message is sent and the LastSentRequest can be accessed.
  4. Take the LastSentRequest and use it to construct the AlgoApiRequest<*>.Sent.

There is still the issue of serializing / deserializing data models using the dotnet sdk. The solution here could be to fallback on the dotnet sdk serializer if the type is not found in the algosdk formatters.

@jasonboukheir jasonboukheir self-assigned this Nov 1, 2022
github-actions bot pushed a commit that referenced this issue Nov 20, 2022
# [4.0.0-pre.1](v3.0.0...v4.0.0-pre.1) (2022-11-20)

### Bug Fixes

* **dotnet sdk:** fix incorrect input to `string.EndsWith` causing compile error in Unity 2020.3 ([c5101ea](c5101ea))

### Features

* **blockchain:** add `StateProofTracking` to the `BlockHeader` ([5d63c9a](5d63c9a))
* **blockchain:** add missing `TxnCommitments` to `BlockHeader` ([be20acb](be20acb))
* **collections:** upgrade to com.unity.collections 1.4.0 ([59663c8](59663c8))
* **dotnet sdk:** add `To*API` methods to `AlgodClient` and `IndexerClient` ([7b292b6](7b292b6))
* **dotnet:** add ability to convert between dotnet and unity types ([8810be2](8810be2))
* **logic:** add `Logic.TealSign` methods for ed25519verify opcodes ([f9de317](f9de317))
* **node services:** add explicit operators to convert from `IAlgoApiClient` to dotnet SDK APIs ([6a657fc](6a657fc)), closes [#157](#157) [#158](#158)
* **services:** add StateProof APIs ([f0eaaf0](f0eaaf0)), closes [#160](#160) [#162](#162)
* **transactions:** add conversion from `AlgoSdk.Sig` to `Algorand.Signature` ([e414732](e414732))
* **transactions:** add conversions between dotnet SDK and Unity SDK signatures ([be039b1](be039b1))

### BREAKING CHANGES

* **blockchain:** Removed `RootTransaction`
* **services:** Algod no longer has `GetProof` method
@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.0-pre.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this issue Feb 27, 2023
# [4.0.0](v3.0.0...v4.0.0) (2023-02-27)

### Bug Fixes

* **2020.3:** change unsupported switch syntax to if statements ([7e57e7a](7e57e7a))
* **account:** fix `TryParse` throwing `NullReferenceException` when given string is null ([142bc3b](142bc3b))
* **algod:** fix `WaitForConfirmation` not respecting `cancellationToken` ([d0b76cd](d0b76cd))
* **asset-store:** change `LinkButton` -> `Button` ([9d7fac2](9d7fac2))
* **asset-store:** move bulk of asset store package to the `Packages` folder ([a78fcc8](a78fcc8)), closes [#178](#178)
* **ci:** republish for http limit ([2d483a8](2d483a8))
* **crypto:** add universal sodium binary ([d3dc173](d3dc173)), closes [#174](#174)
* **crypto:** use proper integer types in sodium interop ([4b4f6e6](4b4f6e6)), closes [#187](#187)
* **dependencies:** add dependencies to ugui and ui ([0849b7c](0849b7c))
* **dotnet sdk:** fix incorrect input to `string.EndsWith` causing compile error in Unity 2020.3 ([c5101ea](c5101ea))
* **dotnet:** fix test compile err ([bc33374](bc33374))
* **dotnet:** use `Algorand2_Unity` instead of `Algorand2` ([3df8515](3df8515))
* **unity-collections:** support unity collections version > 2.x.x ([025a153](025a153)), closes [#192](#192)
* **walletconnect:** fix invalid chain id in wallet connect ([abdedaf](abdedaf))
* **walletconnect:** handle server error messages in payloads ([4b4b4e1](4b4b4e1)), closes [#173](#173)
* **webgl:** use `NativeWebSocketClient` in editor ([5188e5f](5188e5f)), closes [#170](#170)

### Code Refactoring

* **account:** remove obsolete signing methods ([304ba87](304ba87))
* **dotnet:** move all dotnet conversions to `Algorand.Unity.Net` ([b0f7124](b0f7124))
* rename `AlgoSdk` to `Algorand.Unity` ([#167](#167)) ([d135635](d135635))
* **sodium:** split libsodium binaries into arm64 and x86_64 ([e3a0510](e3a0510)), closes [#155](#155)
* **support:** remove support for 2020.3 and add support for 2022.2 ([f000cd4](f000cd4))

### Features

* **account:** add `Address.TryParse` method ([e83ad26](e83ad26))
* **accounts:** add combined interfaces for `Account` and `Signer` ([6cfee78](6cfee78))
* **algod:** add `LedgerStateDelta` APIs and Models ([321b013](321b013))
* **blockchain:** add `StateProofTracking` to the `BlockHeader` ([5d63c9a](5d63c9a))
* **blockchain:** add missing `TxnCommitments` to `BlockHeader` ([be20acb](be20acb))
* **collections:** upgrade to com.unity.collections 1.4.0 ([59663c8](59663c8))
* **dotnet sdk:** add `To*API` methods to `AlgodClient` and `IndexerClient` ([7b292b6](7b292b6))
* **dotnet:** add ability to convert between dotnet and unity types ([8810be2](8810be2))
* **dotnet:** add conversion from `Algorand.Crypto.KeyPair` to `Algorand.Unity.PrivateKey` ([cfa72ff](cfa72ff))
* **dotnet:** add conversion from `Algorand.Unity.Account` to `Algorand.Algod.Model.Account` ([9691d0e](9691d0e))
* **dotnet:** add conversion from `Algorand.Unity.PrivateKey` to `Algorand.Crypto` types ([#168](#168)) ([8e8e0f5](8e8e0f5))
* **dotnet:** update `Algorand.dll` to 1.0.0.14 ([13cf117](13cf117))
* **dotnet:** update `Algorand.dll` to version 1.0.0.15 ([3ce4d6c](3ce4d6c))
* **logic:** add `Logic.TealSign` methods for ed25519verify opcodes ([f9de317](f9de317))
* **node services:** add explicit operators to convert from `IAlgoApiClient` to dotnet SDK APIs ([6a657fc](6a657fc)), closes [#157](#157) [#158](#158)
* **services:** add StateProof APIs ([f0eaaf0](f0eaaf0)), closes [#160](#160) [#162](#162)
* **transactions:** add conversion from `AlgoSdk.Sig` to `Algorand.Signature` ([e414732](e414732))
* **transactions:** add conversions between dotnet SDK and Unity SDK signatures ([be039b1](be039b1))

### Performance Improvements

* **websocket:** change `WebSocketEvent` to be a struct ([1ae34c2](1ae34c2))

### BREAKING CHANGES

* **support:** Unity 2020.3 is no longer supported
* **dotnet:** Removed all explicit/implicit operators to convert Algorand.Unity types to Algorand
types. All conversions now can be done with `ToUnity` and `ToDotnet` extension methods by
referencing the `Algorand.Unity.Net` assembly.
* **sodium:** Unity 2020.3 is no longer supported
* All `AlgoSdk` namespaces are now renamed to `Algorand.Unity`. A simple find and
replace should fix it.
* **account:** Obsolete methods in `Account` class relating to signing have been removed.
* **blockchain:** Removed `RootTransaction`
* **services:** Algod no longer has `GetProof` method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant