| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | public class TransactionBridge : MonoBehaviour |
| | 4 | | { |
| | 5 | | public ITransactionHUDController transactionController; |
| | 6 | |
|
| | 7 | | [System.Serializable] |
| | 8 | | class RequestWeb3ApiUseMessage |
| | 9 | | { |
| | 10 | | [System.Serializable] |
| | 11 | | public class RequestWeb3ApiUsePayload |
| | 12 | | { |
| | 13 | | public string sceneId; |
| | 14 | | public string message; |
| | 15 | | public string toAddress; |
| | 16 | | public float amount; |
| | 17 | | public string currency; |
| | 18 | | } |
| | 19 | | public string id; |
| | 20 | | public string requestType; |
| | 21 | | public RequestWeb3ApiUsePayload payload; |
| | 22 | | } |
| | 23 | |
|
| | 24 | | public void RequestWeb3ApiUse(string payload) |
| | 25 | | { |
| 0 | 26 | | if (transactionController == null) |
| 0 | 27 | | return; |
| | 28 | |
|
| 0 | 29 | | var model = JsonUtility.FromJson<RequestWeb3ApiUseMessage>(payload); |
| | 30 | |
|
| 0 | 31 | | var requestType = DCL.TransactionHUDModel.Type.REQUIRE_PAYMENT; |
| 0 | 32 | | switch (model.requestType) |
| | 33 | | { |
| | 34 | | case "requirePayment": |
| 0 | 35 | | requestType = DCL.TransactionHUDModel.Type.REQUIRE_PAYMENT; |
| 0 | 36 | | break; |
| | 37 | | case "signMessage": |
| 0 | 38 | | requestType = DCL.TransactionHUDModel.Type.SIGN_MESSAGE; |
| 0 | 39 | | break; |
| | 40 | | case "sendAsync": |
| 0 | 41 | | requestType = DCL.TransactionHUDModel.Type.SEND_ASYNC; |
| | 42 | | break; |
| | 43 | | } |
| | 44 | |
|
| 0 | 45 | | transactionController.ShowTransaction(new DCL.TransactionHUDModel.Model |
| | 46 | | { |
| | 47 | | id = model.id, |
| | 48 | | requestType = requestType, |
| | 49 | | sceneId = model.payload.sceneId, |
| | 50 | | message = model.payload.message, |
| | 51 | | toAddress = model.payload.toAddress, |
| | 52 | | amount = model.payload.amount, |
| | 53 | | currency = model.payload.currency |
| | 54 | | }); |
| 0 | 55 | | } |
| | 56 | | } |