repositories {
flatDir {
dirs 'libs'
}
}
implementation(name: 'mathwalletlib-release', ext: 'aar')
<activity android:name="com.medishares.mathwalletlib.RouterActivity">
<intent-filter>
<data
android:host="customhost"
android:scheme="customscheme"/>
<data/>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
设置自定义的host以及scheme
MathWalletLogin mathWalletLogin = new MathWalletLogin();
mathWalletLogin.setBlockchain("eosio"); //公链标识(eosio、eosforce、ethereum等)
mathWalletLogin.setAction("login"); //登录
mathWalletLogin.setDappName("麦子钱包测试—SDK"); //dapp名字
mathWalletLogin.setDappIcon("http://medishares.oss-cn-hongkong.aliyuncs.com/logo/mds-parity.png");//dapp图标Url
mathWalletLogin.setUuID(UUID.randomUUID().toString()); //登录验证唯一标识
mathWalletLogin.setLoginUrl(null);//app跳转登录, 则设置loginUrl 为空,
mathWalletLogin.setExpired(1538100593l); //登录过期时间
mathWalletLogin.setLoginMemo("这是登录测试"); //备注信息,可选
mathWalletLogin.setCallback("customscheme://customhost?action=login"); //回调,scheme和host务必和RouterActivity在xml中设置的相同
MathWalletManager.getInstance().requestLogin(this, mathWalletLogin, new MathWalletCallBack() {
@Override
public void callBack(Map<String, String> params, String uriString) {
//回调返回账号名或地址,如果是eos 则附带权限
LogUtil.e(TAG, new JSONObject(params).toString());
LogUtil.e(TAG, uriString);
}
});
MathWalletPay mathWalletPay = new MathWalletPay();
mathWalletPay.setBlockchain("eosio"); //公链标识(eosio、eosforce、ethereum等)
mathWalletPay.setAction("transfer"); //支付
mathWalletPay.setDappName("麦子钱包测试SDK"); //dapp名字
mathWalletPay.setDappIcon("http://medishares.oss-cn-hongkong.aliyuncs.com/logo/mds-parity.png");//dapp图标Url
mathWalletPay.setFrom("account11"); //付款人
mathWalletPay.setTo("account12"); //收款人
mathWalletPay.setAmount("1.2345"); //转账数量
mathWalletPay.setContract("eosio.token"); //合约地址
mathWalletPay.setSymbol("EOS"); //token名称
mathWalletPay.setPrecision(4); //转账token精度
mathWalletPay.setDappData("麦子钱包dapp测试");//memo or data
mathWalletPay.setDesc("这是支付测试"); //交易的说明信息
mathWalletPay.setExpired(1538100593l); //交易过期时间
mathWalletPay.setCallback("customscheme://customhost?action=transfer"); //回调,scheme和host务必和RouterActivity在xml中设置的相同
MathWalletManager.getInstance().requestPay(this, mathWalletPay, new MathWalletCallBack() {
@Override
public void callBack(Map<String, String> params, String uriString) {
LogUtil.e(TAG, new JSONObject(params).toString());
LogUtil.e(TAG, uriString);
}
});
MathWalletAction mathWalletAction = new MathWalletAction();
mathWalletAction.setBlockchain("eosio"); //公链标识
mathWalletAction.setAction("transaction"); //支付
mathWalletAction.setDappName("麦子钱包测试SDK"); //dapp名字
mathWalletAction.setDappIcon("http://medishares.oss-cn-hongkong.aliyuncs.com/logo/mds-parity.png");//dapp图标Url
mathWalletAction.setFrom("eosmedishares"); //付款人
mathWalletAction.setDappData("麦子钱包dapp测试");//memo or data
mathWalletAction.setDesc("这是ACTION测试"); //交易的说明信息
mathWalletAction.setExpired(1538100593l); //交易过期时间
ArrayList<Action> actions = new ArrayList<>();
Action action = new Action();
action.setCode("eosio");
action.setAction("delegatebw");
action.setBinargs("a09865fe4c9c0761c0a6eb6c1acda891010000000000000004454f5300000000010000000000000004454f530000000000");
actions.add(action);
mathWalletAction.setActions(actions);
mathWalletAction.setCallback("customscheme://customhost?action=transaction"); //回调,scheme和host务必和RouterActivity在xml中设置的相同
MathWalletManager.getInstance().requestAction(this, mathWalletAction, new MathWalletCallBack() {
@Override
public void callBack(Map<String, String> params, String uriString) {
LogUtil.e(TAG, new JSONObject(params).toString());
LogUtil.e(TAG, uriString);
}
});
MathWalletUrl mathWalletUrl = new MathWalletUrl("http://eosrand.io/?ref=maoguangxing"); //dappUrl
mathWalletUrl.setBlockchain("eosio"); //公链标识 eosio,eosforce,ethereum
MathWalletManager.getInstance().reqeustOpenUrl(this, mathWalletUrl);
MathWalletSignMessage mathWalletSignMessage = new MathWalletSignMessage();
mathWalletSignMessage.setCallback("customscheme://customhost?action=signMessage");
mathWalletSignMessage.setIsHash(false);
mathWalletSignMessage.setMessage("这是一条测试数据");
mathWalletSignMessage.setBlockchain("eosio");
mathWalletSignMessage.setDappIcon("http://medishares.oss-cn-hongkong.aliyuncs.com/logo/mds-parity.png");//dapp图标Url
mathWalletSignMessage.setDappName("这是测试的签名数据");
MathWalletManager.getInstance().requestSignMessage(this, mathWalletSignMessage, new MathWalletCallBack() {
@Override
public void callBack(Map<String, String> params, String uriString) {
LogUtil.e(TAG, new JSONObject(params).toString());
LogUtil.e(TAG, uriString);
}
});