2016-06-14 11:19:56 +00:00
|
|
|
status.command({
|
|
|
|
name: "location",
|
2016-10-31 13:41:47 +00:00
|
|
|
icon: "location",
|
2016-11-10 08:33:44 +00:00
|
|
|
title: "Location",
|
|
|
|
description: "Share your location",
|
2016-10-31 13:41:47 +00:00
|
|
|
color: "#a187d5",
|
2016-06-29 11:28:43 +00:00
|
|
|
preview: function (params) {
|
2016-07-07 16:09:16 +00:00
|
|
|
var text = status.components.text(
|
2016-06-29 11:28:43 +00:00
|
|
|
{
|
|
|
|
style: {
|
|
|
|
marginTop: 5,
|
|
|
|
marginHorizontal: 0,
|
|
|
|
fontSize: 14,
|
|
|
|
fontFamily: "font",
|
|
|
|
color: "black"
|
|
|
|
}
|
2016-10-21 14:42:08 +00:00
|
|
|
}, params.address);
|
2016-06-29 11:28:43 +00:00
|
|
|
var uri = "https://maps.googleapis.com/maps/api/staticmap?center="
|
2016-10-21 14:42:08 +00:00
|
|
|
+ params.address
|
2016-06-29 11:28:43 +00:00
|
|
|
+ "&size=100x100&maptype=roadmap&key=AIzaSyBNsj1qoQEYPb3IllmWMAscuXW0eeuYqAA&language=en"
|
|
|
|
+ "&markers=size:mid%7Ccolor:0xff0000%7Clabel:%7C"
|
2016-10-21 14:42:08 +00:00
|
|
|
+ params.address;
|
2016-06-29 11:28:43 +00:00
|
|
|
|
|
|
|
var image = status.components.image(
|
|
|
|
{
|
|
|
|
source: {uri: uri},
|
|
|
|
style: {
|
|
|
|
width: 100,
|
|
|
|
height: 100
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
return status.components.view({}, [text, image]);
|
|
|
|
}
|
2016-06-14 11:19:56 +00:00
|
|
|
}).param({
|
|
|
|
name: "address",
|
2016-06-27 15:38:44 +00:00
|
|
|
type: status.types.TEXT,
|
|
|
|
placeholder: "Address"
|
2016-06-14 11:19:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-09-21 09:42:59 +00:00
|
|
|
function browseSuggestions(params) {
|
2016-10-21 14:42:08 +00:00
|
|
|
if (params.url && params.url !== "undefined" && params.url != "") {
|
|
|
|
var url = params.url;
|
2016-07-18 07:38:24 +00:00
|
|
|
if (!/^[a-zA-Z-_]+:/.test(url)) {
|
|
|
|
url = 'http://' + url;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {webViewUrl: url};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
status.command({
|
|
|
|
name: "browse",
|
2016-11-10 08:33:44 +00:00
|
|
|
title: "Browser",
|
|
|
|
description: "Launch the browser",
|
2016-07-18 07:38:24 +00:00
|
|
|
color: "#ffa500",
|
|
|
|
fullscreen: true,
|
|
|
|
suggestionsTrigger: 'on-send',
|
|
|
|
params: [{
|
2016-10-21 14:42:08 +00:00
|
|
|
name: "url",
|
2016-09-21 09:42:59 +00:00
|
|
|
suggestions: browseSuggestions,
|
2016-07-18 07:38:24 +00:00
|
|
|
type: status.types.TEXT
|
|
|
|
}]
|
|
|
|
});
|
2016-06-30 16:00:44 +00:00
|
|
|
|
2016-11-10 14:02:39 +00:00
|
|
|
function validateSend(params, context) {
|
|
|
|
if (!context.to) {
|
|
|
|
return {
|
|
|
|
errors: [
|
|
|
|
status.components.validationMessage(
|
|
|
|
"Wrong address",
|
|
|
|
"Recipient address must be specified"
|
|
|
|
)
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
2016-10-11 14:24:52 +00:00
|
|
|
if (!params.amount) {
|
2016-09-20 14:15:29 +00:00
|
|
|
return {
|
|
|
|
errors: [
|
|
|
|
status.components.validationMessage(
|
|
|
|
"Amount",
|
|
|
|
"Amount must be specified"
|
|
|
|
)
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-06-30 16:00:44 +00:00
|
|
|
try {
|
2016-10-11 14:24:52 +00:00
|
|
|
var val = web3.toWei(params.amount, "ether");
|
2016-06-30 16:00:44 +00:00
|
|
|
} catch (err) {
|
|
|
|
return {
|
|
|
|
errors: [
|
|
|
|
status.components.validationMessage(
|
|
|
|
"Amount",
|
2016-10-11 14:24:52 +00:00
|
|
|
"Amount is not valid number"
|
2016-06-30 16:00:44 +00:00
|
|
|
)
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
2016-08-03 13:15:04 +00:00
|
|
|
|
2016-10-11 14:24:52 +00:00
|
|
|
var balance = web3.eth.getBalance(context.from);
|
2016-06-30 16:00:44 +00:00
|
|
|
if (bn(val).greaterThan(bn(balance))) {
|
|
|
|
return {
|
|
|
|
errors: [
|
|
|
|
status.components.validationMessage(
|
|
|
|
"Amount",
|
|
|
|
"Not enough ETH on balance ("
|
|
|
|
+ web3.fromWei(balance, "ether")
|
|
|
|
+ " ETH)"
|
|
|
|
)
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-11 14:24:52 +00:00
|
|
|
function sendTransaction(params, context) {
|
2016-06-30 16:00:44 +00:00
|
|
|
var data = {
|
2016-10-11 14:24:52 +00:00
|
|
|
from: context.from,
|
|
|
|
to: context.to,
|
|
|
|
value: web3.toWei(params.amount, "ether")
|
2016-06-30 16:00:44 +00:00
|
|
|
};
|
|
|
|
|
2016-10-11 14:24:52 +00:00
|
|
|
try {
|
|
|
|
return web3.eth.sendTransaction(data);
|
|
|
|
} catch (err) {
|
|
|
|
return {error: err};
|
|
|
|
}
|
2016-06-30 16:00:44 +00:00
|
|
|
}
|
|
|
|
|
2016-10-20 13:51:37 +00:00
|
|
|
var send = {
|
2016-06-30 16:00:44 +00:00
|
|
|
name: "send",
|
2016-10-31 13:41:47 +00:00
|
|
|
icon: "money_white",
|
2016-06-30 16:00:44 +00:00
|
|
|
color: "#5fc48d",
|
2016-11-10 08:33:44 +00:00
|
|
|
title: "Send ETH",
|
|
|
|
description: "Send a payment",
|
2016-06-30 16:00:44 +00:00
|
|
|
params: [{
|
|
|
|
name: "amount",
|
|
|
|
type: status.types.NUMBER
|
|
|
|
}],
|
2016-11-16 07:39:28 +00:00
|
|
|
preview: function (params, context) {
|
|
|
|
var amountStyle = {
|
|
|
|
fontSize: 36,
|
|
|
|
color: "#000000"
|
|
|
|
};
|
|
|
|
|
|
|
|
var isIos = context.platform == "ios";
|
|
|
|
if (isIos) {
|
|
|
|
amountStyle.height = 36;
|
|
|
|
} else {
|
|
|
|
amountStyle.lineHeight = 34;
|
|
|
|
}
|
|
|
|
|
|
|
|
var amount = status.components.view(
|
|
|
|
{
|
|
|
|
flexDirection: "row",
|
|
|
|
alignItems: "flex-end"
|
|
|
|
},
|
|
|
|
[status.components.text(
|
|
|
|
{
|
|
|
|
style: amountStyle,
|
|
|
|
font: "light"
|
|
|
|
},
|
|
|
|
params.amount
|
|
|
|
)]);
|
|
|
|
|
|
|
|
var currency = status.components.view(
|
|
|
|
{
|
|
|
|
style: {
|
|
|
|
flexDirection: "column",
|
|
|
|
justifyContent: "flex-end",
|
|
|
|
paddingBottom: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
[status.components.text(
|
|
|
|
{
|
|
|
|
style: {
|
|
|
|
color: "#9199a0",
|
|
|
|
fontSize: 16,
|
|
|
|
lineHeight: 18,
|
|
|
|
marginLeft: 7.5
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"ETH"
|
|
|
|
)]
|
|
|
|
);
|
|
|
|
|
|
|
|
return status.components.view(
|
|
|
|
{
|
|
|
|
style: {
|
|
|
|
flexDirection: "row",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
marginTop: 8,
|
|
|
|
marginBottom: 8
|
|
|
|
}
|
|
|
|
},
|
|
|
|
[amount, currency]
|
2016-06-30 16:00:44 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
handler: sendTransaction,
|
2016-11-10 14:02:39 +00:00
|
|
|
validator: validateSend
|
2016-10-20 13:51:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
status.command(send);
|
|
|
|
status.response(send);
|
|
|
|
|
|
|
|
status.command({
|
|
|
|
name: "request",
|
2016-11-10 08:33:44 +00:00
|
|
|
title: "Request ETH",
|
2016-10-20 13:51:37 +00:00
|
|
|
color: "#7099e6",
|
2016-11-10 08:33:44 +00:00
|
|
|
description: "Request a payment",
|
2016-10-20 13:51:37 +00:00
|
|
|
params: [{
|
|
|
|
name: "amount",
|
|
|
|
type: status.types.NUMBER
|
|
|
|
}],
|
|
|
|
preview: function (params) {
|
|
|
|
return status.components.text(
|
|
|
|
{},
|
|
|
|
params.amount + " ETH"
|
|
|
|
);
|
|
|
|
},
|
|
|
|
handler: function (params) {
|
|
|
|
return {
|
|
|
|
event: "request",
|
|
|
|
params: [params.amount]
|
|
|
|
request: {
|
|
|
|
command: "send",
|
|
|
|
params: {
|
|
|
|
amount: params.amount
|
|
|
|
},
|
|
|
|
content: "Requesting " + params.amount + "ETH"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
2016-06-30 16:00:44 +00:00
|
|
|
});
|