Migrating to Unity SDK v0.4.0
- Converted to Unity Package Manager (UPM) format
- Deprecated
Waypoint.BindOnResponse()
andWaypoint.UnBindOnResponse()
- Unified
Waypoint.Init()
intoWaypoint.SetUp()
- Unified
Waypoint.OnAuthorize()
andWaypoint.OnGetIDToken()
intoWaypoint.Authorize()
- Renamed signing methods for consistency:
OnPersonalSign()
→PersonalSign()
OnSignTypeData()
→SignTypedData()
- Renamed transaction methods:
SendTransaction()
→SendNativeToken()
OnCallContract()
→WriteContract()
Major changes
- Unity Package Manager Support
- Improved method naming
- Simplified Methods: Cross-platform unification of Authorize, SetUp, and others.
- Improved Consistency: Renamed signing and transaction methods.
- Resource Cleanup: Introduced Waypoint.CleanUp().
Deprecated methods
While these methods still work in older versions, we strongly recommend upgrading to v0.4.0
. These methods will be removed in v0.5.0
.
Waypoint.BindOnResponse()
andWaypoint.UnBindOnResponse()
(completely removed in v0.4.0)Waypoint.Init()
Waypoint.OnAuthorize()
andWaypoint.OnGetIDToken()
Waypoint.OnPersonalSign()
andWaypoint.OnSignTypeData()
Waypoint.SendTransaction()
Waypoint.OnCallContract()
Migration Guide
Install via UPM
SDK is now available in UPM format for easier management. Add it via Git URL:
https://github.com/skymavis/waypoint-unity.git#v0.4.0
Or update Packages/manifest.json
:
{
"dependencies": {
// Previous dependencies
"com.skymavis.waypoint": "https://github.com/skymavis/waypoint-unity.git#v0.4.0",
}
}
Deprecated Waypoint.BindOnResponse()
and Waypoint.UnBindOnResponse()
Manually binding/unbinding is replaced with the Waypoint.ResponseReceived
event:
using System.Threading.Tasks;
public async Task<string> WaitForResponse(string id)
{
string responseData = null;
string currentId = id;
void dataCallback(string state, string data) { if (currentId == state) responseData = data; }
SkyMavis.Waypoint.BindOnResponse(dataCallback);
while (string.IsNullOrEmpty(responseData) && currentId == _responseId) await Task.Yield();
SkyMavis.Waypoint.UnBindOnResponse(dataCallback);
var tcs = new TaskCompletionSource<string>();
Waypoint.ResponseReceived += Callback;
return tcs.Task;
void Callback(string state, string data)
{
if (state == id)
{
Waypoint.ResponseReceived -= Callback;
tcs.SetResult(data);
}
}
}
Unified Waypoint.Init()
into Waypoint.SetUp()
Initialize SDK with the new WaypointSettings
structure for better configurability:
void Start()
{
string waypointOrigin = "https://waypoint.roninchain.com";
string clientId = "${YOUR_CLIENT_ID}";
string deeplinkSchema = "mydapp://open";
string rpcUrl = "https://saigon-testnet.roninchain.com/rpc";
int chainId = 2021;
SkyMavis.Waypoint.Init(waypointOrigin, clientId, deeplinkSchema, rpcUrl, chainId);
WaypointSettings settings = new WaypointSettings()
{
endpoint = waypointOrigin,
clientID = clientId,
deepLinkCallbackURL = deeplinkSchema,
network = new WaypointSettings.Network()
{
rpcURL = rpcUrl,
chainID = chainId
}
// Add other settings here
};
Waypoint.SetUp(settings);
}
Unified Waypoint.OnAuthorize()
and Waypoint.OnGetIDToken()
into Waypoint.Authorize()
To get the user's ID token and wallet addresses, use the unified Waypoint.Authorize()
method across all platforms.
// Desktop (Mavis Hub) - v0.3.0
public async void OnGetIDTokenClicked()
{
_responseId = SkyMavis.Waypoint.OnGetIDToken();
string responseData = await WaitForWaypointResponse(_responseId);
Debug.Log("Get ID Token response : " + responseData);
}
// Android & iOS - v0.3.0
public async void OnAuthorizeClicked()
{
_responseId = SkyMavis.Waypoint.OnAuthorize();
string responseData = await WaitForMavisIdResponse(_responseId);
Debug.Log("Authorize response : " + responseData);
}
// Cross-platform - v0.4.0
public async void OnAuthorizeClicked()
{
string scope = "email profile openid wallet";
_responseId = Waypoint.Authorize(scope);
string responseData = await WaitForResponse(_responseId);
Debug.Log("Authorize response : " + responseData);
}
Replaced Waypoint.OnPersonalSign()
with Waypoint.PersonalSign()
public async void OnPersonalSignClicked()
{
string message = "Hello Axie Infinity";
_responseId = Waypoint.OnPersonalSign(message);
_responseId = Waypoint.PersonalSign(message);
string responseData = await WaitForResponse(_responseId);
Debug.Log("Personal sign response: " + responseData);
}
Replaced Waypoint.OnSignTypeData()
with Waypoint.SignTypedData()
public async void OnSignTypedDataClicked()
{
string typedData = @"{""types"":{""Asset"":[{""name"":""erc"",""type"":""uint8""},{""name"":""addr"",""type"":""address""},{""name"":""id"",""type"":""uint256""},{""name"":""quantity"",""type"":""uint256""}],""Order"":[{""name"":""maker"",""type"":""address""},{""name"":""kind"",""type"":""uint8""},{""name"":""assets"",""type"":""Asset[]""},{""name"":""expiredAt"",""type"":""uint256""},{""name"":""paymentToken"",""type"":""address""},{""name"":""startedAt"",""type"":""uint256""},{""name"":""basePrice"",""type"":""uint256""},{""name"":""endedAt"",""type"":""uint256""},{""name"":""endedPrice"",""type"":""uint256""},{""name"":""expectedState"",""type"":""uint256""},{""name"":""nonce"",""type"":""uint256""},{""name"":""marketFeePercentage"",""type"":""uint256""}],""EIP712Domain"":[{""name"":""name"",""type"":""string""},{""name"":""version"",""type"":""string""},{""name"":""chainId"",""type"":""uint256""},{""name"":""verifyingContract"",""type"":""address""}]}, ""domain"":{""name"":""MarketGateway"",""version"":""1"",""chainId"":2021,""verifyingContract"":""0xfff9ce5f71ca6178d3beecedb61e7eff1602950e""},""primaryType"":""Order"",""message"":{""maker"":""0xd761024b4ef3336becd6e802884d0b986c29b35a"",""kind"":""1"",""assets"":[{""erc"":""1"",""addr"":""0x32950db2a7164ae833121501c797d79e7b79d74c"",""id"":""2730069"",""quantity"":""0""}],""expiredAt"":""1721709637"",""paymentToken"":""0xc99a6a985ed2cac1ef41640596c5a5f9f4e19ef5"",""startedAt"":""1705984837"",""basePrice"":""500000000000000000"",""endedAt"":""0"",""endedPrice"":""0"",""expectedState"":""0"",""nonce"":""0"",""marketFeePercentage"":""425""}}";
_responseId = Waypoint.OnSignTypeData(typedData);
_responseId = Waypoint.SignTypedData(typedData);
string responseData = await WaitForResponse(_responseId);
Debug.Log("Sign typed data response " + responseData);
}
Replaced Waypoint.SendTransaction()
with Waypoint.SendNativeToken()
public async void OnSendRonClicked()
{
string receiverAddress = "0xD36deD8E1927dCDD76Bfe0CC95a5C1D65c0a807a";
string value = "100000000000000000";
_responseId = Waypoint.SendTransaction(receiverAddress, value);
_responseId = Waypoint.SendNativeToken(receiverAddress, value);
string responseData = await WaitForResponse(_responseId);
Debug.Log("Send response data in Unity : " + responseData);
}
Replaced Waypoint.OnCallContract()
with Waypoint.WriteContract()
public async void OnApproveErc20Clicked()
{
string contractAddress = "0x3c4e17b9056272ce1b49f6900d8cfd6171a1869d";
string readableAbi = "function approve(address _spender, uint256 _value)";
var approveParams = new { _spender = "0x6B190089ed7F75Fe17B3b0A17F6ebd69f72c3F63", _value = 1000000000000000000 };
try
{
var data = ABI.EncodeFunctionData(readableAbi, approveParams);
Debug.Log("Approve data: " + data);
_responseId = Waypoint.OnCallContract(contractAddress, data);
_responseId = Waypoint.WriteContract(contractAddress, readableAbi, approveParams);
string responseData = await WaitForResponse(_responseId);
Debug.Log(responseData);
}
catch (System.Exception e)
{
Debug.Log("Error in call contract: " + e.Message);
}
}
Resources cleanup with Waypoint.CleanUp()
Clean up managed resources when SDK is no longer in use:
void OnDestroy()
{
Waypoint.CleanUp();
}
Summary
We’ve made major improvements for consistency, cross-platform support, and resource management. If you encounter any issues, please open an issue on GitHub or reach out on our Discord server.