diff --git a/package-lock.json b/package-lock.json
index fb87255f..d461cd98 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -1032,18 +1032,18 @@
"integrity": "sha512-4zAPlpDEh2VwXswwr/t8xGNDGg8RQiPxtxZ3qQEXyQsBV39ptTdESCjuBvGze1nLMVrxmTIKmnO/nAV8Tqjjzg=="
},
"@polkadot/api": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/api/-/api-0.79.1.tgz",
- "integrity": "sha512-AXNT55vm8p93oVC8eXF0HMr5DHQsK+rOEbOUCAwgdfewz0aHUmyXDl7PjFRW2dLSQPj3gG4MHoj4Lw6F88lUBQ==",
+ "version": "0.82.0-beta.23",
+ "resolved": "https://registry.npmjs.org/@polkadot/api/-/api-0.82.0-beta.23.tgz",
+ "integrity": "sha512-/yMie1gKG9H4Y0/ia2+Un26xCJbvXaMIJjcf8vWsUvMBSSbl1bg/uorRW3FY6e43pb3UzKrv1CLkqN1AhAmK6A==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/api-derive": "^0.79.1",
- "@polkadot/extrinsics": "^0.79.1",
- "@polkadot/rpc-provider": "^0.79.1",
- "@polkadot/rpc-rx": "^0.79.1",
- "@polkadot/storage": "^0.79.1",
- "@polkadot/types": "^0.79.1",
- "@polkadot/util-crypto": "^0.91.1"
+ "@polkadot/api-derive": "^0.82.0-beta.23",
+ "@polkadot/extrinsics": "^0.82.0-beta.23",
+ "@polkadot/rpc-core": "^0.82.0-beta.23",
+ "@polkadot/rpc-provider": "^0.82.0-beta.23",
+ "@polkadot/storage": "^0.82.0-beta.23",
+ "@polkadot/types": "^0.82.0-beta.23",
+ "@polkadot/util-crypto": "^0.94.0-beta.4"
},
"dependencies": {
"@babel/runtime": {
@@ -1053,22 +1053,17 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
"@polkadot/api-derive": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-0.79.1.tgz",
- "integrity": "sha512-VHIClyj9+7d32JfCI5JH6pPLIPT1gQMJiPsRtxmVdmvtySWE4njcJYVdcw/vvclCnljoNzvSAXp/fICSBnmkdA==",
+ "version": "0.82.0-beta.23",
+ "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-0.82.0-beta.23.tgz",
+ "integrity": "sha512-ax9i8nmejG6GpaTh58NUKzwiRGF9qXOB45n+yZjpR8jM5WAtkGQN1tY9qmau2Vqm+meyggEA5t7hDvsj8s81KQ==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/api": "^0.79.1",
- "@polkadot/types": "^0.79.1",
+ "@polkadot/api": "^0.82.0-beta.23",
+ "@polkadot/types": "^0.82.0-beta.23",
"@types/memoizee": "^0.4.2",
"memoizee": "^0.4.14"
},
@@ -1080,22 +1075,17 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
"@polkadot/extrinsics": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/extrinsics/-/extrinsics-0.79.1.tgz",
- "integrity": "sha512-4OlVp8Crvnx8t4LimZFLOIexu54MA1quMr3YVwf8Kv7kbRCkeAScNaFg9mKnl7DHasTPRI4LR+bTEvfSqypxCA==",
+ "version": "0.82.0-beta.23",
+ "resolved": "https://registry.npmjs.org/@polkadot/extrinsics/-/extrinsics-0.82.0-beta.23.tgz",
+ "integrity": "sha512-qUXnJ2L1G7oSQhKBo26Nrl72XNAhs/cmrBebxgzSbbrbjZWy8LoOAn6JnmhflfDT/TCnDaQKBZP04OC68a/QkA==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/types": "^0.79.1",
- "@polkadot/util": "^0.91.1"
+ "@polkadot/types": "^0.82.0-beta.23",
+ "@polkadot/util": "^0.94.0-beta.4"
},
"dependencies": {
"@babel/runtime": {
@@ -1105,18 +1095,13 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
"@polkadot/jsonrpc": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/jsonrpc/-/jsonrpc-0.79.1.tgz",
- "integrity": "sha512-J7FhDQgcfii+1WG8wkBPa19BbwqmT5YRXGwrL+ZLelGnp9ypXJ4KJNMTspsmqIeoP9JE+6NIAS3vHoWM814cFw==",
+ "version": "0.82.0-beta.23",
+ "resolved": "https://registry.npmjs.org/@polkadot/jsonrpc/-/jsonrpc-0.82.0-beta.23.tgz",
+ "integrity": "sha512-DASPowM0XDgC8IE/OtKvJ5VnPmzuVB/gxLna7H1wctYCfQCi5Te79F4uOnh54XSu7D6uqBKtloyrtexBYTlVkA==",
"requires": {
"@babel/runtime": "^7.4.5"
},
@@ -1128,22 +1113,17 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
"@polkadot/keyring": {
- "version": "0.91.1",
- "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-0.91.1.tgz",
- "integrity": "sha512-XYWbqWK8CAeuPFg1llS65r2sO7k2qTalJMHPQiaIVETPXQGx4SCzzMzBkD9eVvHTs9KfamynOQrspflhjHtgbg==",
+ "version": "0.93.1",
+ "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-0.93.1.tgz",
+ "integrity": "sha512-sJ9E9AKcJASdnkbzBA1L773oPgXAkEF3LsUjpkaDTelPqzsky6hdyglj3oQpkCj6Oofd1BwJeonmqinIV8Fl4Q==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/util": "^0.91.1",
- "@polkadot/util-crypto": "^0.91.1",
+ "@polkadot/util": "^0.93.1",
+ "@polkadot/util-crypto": "^0.93.1",
"@types/bs58": "^4.0.0",
"bs58": "^4.0.1"
},
@@ -1156,23 +1136,55 @@
"regenerator-runtime": "^0.13.2"
}
},
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
+ "@polkadot/util": {
+ "version": "0.93.1",
+ "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-0.93.1.tgz",
+ "integrity": "sha512-ORqpaCf7pDtg07/TVPnXyEKTyL7YhlTT9xFU1UFv3WoTLPrGThFlZnWQrfOVYuuMtlnsdpt2evJ1i5V9alGdOQ==",
+ "requires": {
+ "@babel/runtime": "^7.4.5",
+ "@types/bn.js": "^4.11.5",
+ "@types/deasync": "^0.1.0",
+ "bn.js": "^4.11.8",
+ "camelcase": "^5.3.1",
+ "chalk": "^2.4.2",
+ "ip-regex": "^4.1.0",
+ "moment": "^2.24.0"
+ }
+ },
+ "@polkadot/util-crypto": {
+ "version": "0.93.1",
+ "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-0.93.1.tgz",
+ "integrity": "sha512-oSTUnJxWQkd6XopK+HFOa8sgTSTJW6LOoTg8iv6QCkddyEhsk8XkTe43AE4F+RA0VOi7MOiiBEl6Pl5eFIer9g==",
+ "requires": {
+ "@babel/runtime": "^7.4.5",
+ "@polkadot/util": "^0.93.1",
+ "@polkadot/wasm-crypto": "^0.11.1",
+ "@types/bip39": "^2.4.2",
+ "@types/pbkdf2": "^3.0.0",
+ "@types/secp256k1": "^3.5.0",
+ "@types/xxhashjs": "^0.2.1",
+ "bip39": "^2.5.0",
+ "blakejs": "^1.1.0",
+ "js-sha3": "^0.8.0",
+ "secp256k1": "^3.7.0",
+ "tweetnacl": "^1.0.1",
+ "xxhashjs": "^0.2.2"
+ }
}
}
},
"@polkadot/rpc-core": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-0.79.1.tgz",
- "integrity": "sha512-jWwwPbihGUwTUR48w9ootK/mpS/2aBsG4KUsSuLgmBSyVNPUA/U19VW7yD3BgMF6GdURAZFCBk3tqKIEjZox9w==",
+ "version": "0.82.0-beta.23",
+ "resolved": "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-0.82.0-beta.23.tgz",
+ "integrity": "sha512-iMQisQctxhGUMvYVrUBKvYpCld5hmK6X3KQcOqJe+5EmycptVNKPabQxi3bo57FSxKTnzLcesnMHljSCyY5aFg==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/jsonrpc": "^0.79.1",
- "@polkadot/rpc-provider": "^0.79.1",
- "@polkadot/types": "^0.79.1",
- "@polkadot/util": "^0.91.1"
+ "@polkadot/jsonrpc": "^0.82.0-beta.23",
+ "@polkadot/rpc-provider": "^0.82.0-beta.23",
+ "@polkadot/types": "^0.82.0-beta.23",
+ "@polkadot/util": "^0.94.0-beta.4",
+ "memoizee": "^0.4.14",
+ "rxjs": "^6.5.2"
},
"dependencies": {
"@babel/runtime": {
@@ -1182,26 +1194,20 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
"@polkadot/rpc-provider": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-0.79.1.tgz",
- "integrity": "sha512-ZRY9S9Mqk9aQyJKBeHzrgpL02SZkH/fHwcmIDZGWI8kJuAP3Yn7LO761K82HMsehkbNCBnxdWB5oJKQ+qlYFrw==",
+ "version": "0.82.0-beta.23",
+ "resolved": "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-0.82.0-beta.23.tgz",
+ "integrity": "sha512-9AOMHB09wISocZZ4j3T28m+a0pIIVZZmfSlkqQkzN+/zWjLk5dJTAaRnxpFacFKSoHbTr9oK1s+SrdHK7p4t7A==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/keyring": "^0.91.1",
- "@polkadot/storage": "^0.79.1",
- "@polkadot/util": "^0.91.1",
- "@polkadot/util-crypto": "^0.91.1",
+ "@polkadot/storage": "^0.82.0-beta.23",
+ "@polkadot/util": "^0.94.0-beta.4",
+ "@polkadot/util-crypto": "^0.94.0-beta.4",
"@types/nock": "^10.0.3",
- "eventemitter3": "^3.1.0",
+ "eventemitter3": "^4.0.0",
"isomorphic-fetch": "^2.2.1",
"websocket": "^1.0.28"
},
@@ -1214,52 +1220,22 @@
"regenerator-runtime": "^0.13.2"
}
},
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
- }
- }
- },
- "@polkadot/rpc-rx": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/rpc-rx/-/rpc-rx-0.79.1.tgz",
- "integrity": "sha512-lf0Z5VUrdvddnw+XcFcdcmmsExO5h+wMN2ILgAm9fZZUC+y+8dxMxFE3vFL2N7CSecFznf0FRr8GMiRJzZTt8w==",
- "requires": {
- "@babel/runtime": "^7.4.5",
- "@polkadot/rpc-core": "^0.79.1",
- "@polkadot/rpc-provider": "^0.79.1",
- "@types/memoizee": "^0.4.2",
- "@types/rx": "^4.1.1",
- "memoizee": "^0.4.14",
- "rxjs": "^6.5.2"
- },
- "dependencies": {
- "@babel/runtime": {
- "version": "7.4.5",
- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.5.tgz",
- "integrity": "sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==",
- "requires": {
- "regenerator-runtime": "^0.13.2"
- }
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
+ "eventemitter3": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz",
+ "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg=="
}
}
},
"@polkadot/storage": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/storage/-/storage-0.79.1.tgz",
- "integrity": "sha512-hyr8n83XFSm0tm5v8XSW8ul3VPfC9ekesjtzgc95jzqQHs3J4ntbyh8rjAOX+IB3EP0W8nI6mvMvHP5MdS7ltQ==",
+ "version": "0.82.0-beta.23",
+ "resolved": "https://registry.npmjs.org/@polkadot/storage/-/storage-0.82.0-beta.23.tgz",
+ "integrity": "sha512-+paqWsdJDazBknqEdqCEftbwJxBuvz1wQcGgk3jxdhaGTi2H5D/aaDv1k2ChkbOywdO2DqiVJAKUiJpzjcPC6Q==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/keyring": "^0.91.1",
- "@polkadot/types": "^0.79.1",
- "@polkadot/util": "^0.91.1",
- "@polkadot/util-crypto": "^0.91.1"
+ "@polkadot/types": "^0.82.0-beta.23",
+ "@polkadot/util": "^0.94.0-beta.4",
+ "@polkadot/util-crypto": "^0.94.0-beta.4"
},
"dependencies": {
"@babel/runtime": {
@@ -1269,22 +1245,17 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
"@polkadot/types": {
- "version": "0.79.1",
- "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-0.79.1.tgz",
- "integrity": "sha512-u7hcubX5Kl3m3IM+YXyORXlgHUJSb+a/YyzalERF7yRxEUW1fPMRE6935cUQT5kHdRme0aANncjHFGbE6Qn0vg==",
+ "version": "0.82.0-beta.23",
+ "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-0.82.0-beta.23.tgz",
+ "integrity": "sha512-4edZf6NrPhA9Co/+f7f7CX9EiVSFp5DjuUW8UcPZkS0yEwFQIjfk8wDizO6rob4txi5gEs+19SQktJ9ERcxAYQ==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/keyring": "^0.91.1",
- "@polkadot/util": "^0.91.1"
+ "@polkadot/util": "^0.94.0-beta.4",
+ "@polkadot/util-crypto": "^0.94.0-beta.4"
},
"dependencies": {
"@babel/runtime": {
@@ -1294,11 +1265,6 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
@@ -1314,9 +1280,9 @@
}
},
"@polkadot/util": {
- "version": "0.91.1",
- "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-0.91.1.tgz",
- "integrity": "sha512-NqW3FlKQl0wh4mt/QpmGduE0VLBSsb6S45pyjgM3P7Fz37EyrOOZa8s7IBdIck2dtY3MwAy8JWGJjpTnMHXh8Q==",
+ "version": "0.94.0-beta.4",
+ "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-0.94.0-beta.4.tgz",
+ "integrity": "sha512-dla3lV/9WVxODJHSytwNXsbRbs/Jx3ewXDyovptxMqHuepAsNlL44szbRZ+umIDG63JlFoI9eycLK+LEXnVnIA==",
"requires": {
"@babel/runtime": "^7.4.5",
"@types/bn.js": "^4.11.5",
@@ -1335,29 +1301,25 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
"@polkadot/util-crypto": {
- "version": "0.91.1",
- "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-0.91.1.tgz",
- "integrity": "sha512-o1CU1fwf0zxTJfuXgWs+IBJ8qIsZK9Pk7dSKR+YcDP3RYYCF8kRp+PDw/BHtvOhSerLKn9rxECjmtk+5sVVzkQ==",
+ "version": "0.94.0-beta.4",
+ "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-0.94.0-beta.4.tgz",
+ "integrity": "sha512-CNzjy92l6zjPm9B1e5plhINtrNKfS2dySExQZeNGJpOUb/dgn2TYzwhoQf4ZAUv0VzLqtgtO4TrwhXtiCFPzRg==",
"requires": {
"@babel/runtime": "^7.4.5",
- "@polkadot/util": "^0.91.1",
- "@polkadot/wasm-crypto": "^0.10.1",
+ "@polkadot/util": "^0.94.0-beta.4",
+ "@polkadot/wasm-crypto": "^0.11.1",
"@types/bip39": "^2.4.2",
+ "@types/bs58": "^4.0.0",
"@types/pbkdf2": "^3.0.0",
"@types/secp256k1": "^3.5.0",
- "@types/webassembly-js-api": "^0.0.2",
"@types/xxhashjs": "^0.2.1",
"bip39": "^2.5.0",
"blakejs": "^1.1.0",
+ "bs58": "^4.0.1",
"js-sha3": "^0.8.0",
"secp256k1": "^3.7.0",
"tweetnacl": "^1.0.1",
@@ -1371,18 +1333,13 @@
"requires": {
"regenerator-runtime": "^0.13.2"
}
- },
- "regenerator-runtime": {
- "version": "0.13.2",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
}
}
},
"@polkadot/wasm-crypto": {
- "version": "0.10.1",
- "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto/-/wasm-crypto-0.10.1.tgz",
- "integrity": "sha512-hI3OYftMGJkDetTe1DeU9aH4euk6WVmAMFszslNrCxHMFFkemEgACykwpyuOdCjv24VZP/cMsrVskKix1GzSYQ=="
+ "version": "0.11.1",
+ "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto/-/wasm-crypto-0.11.1.tgz",
+ "integrity": "sha512-zd4p5UjsUlr4oW/5IWKEODHX7VKa6dc94oD8WJSr7++f+UGxSpF84qW+h+16uMDhU5PbHqq31dv1w73cr+KP4Q=="
},
"@react-native-community/cli": {
"version": "1.9.8",
@@ -1604,9 +1561,9 @@
}
},
"@types/node": {
- "version": "12.0.8",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.8.tgz",
- "integrity": "sha512-b8bbUOTwzIY3V5vDTY1fIJ+ePKDUBqt2hC2woVGotdQQhG/2Sh62HOKHrT7ab+VerXAcPyAiTEipPu/FsreUtg=="
+ "version": "12.0.10",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.10.tgz",
+ "integrity": "sha512-LcsGbPomWsad6wmMNv7nBLw7YYYyfdYcz6xryKYQhx89c3XXan+8Q6AJ43G5XDIaklaVkK3mE4fCb0SBvMiPSQ=="
},
"@types/normalize-package-data": {
"version": "2.4.0",
@@ -1647,119 +1604,6 @@
"@types/react": "*"
}
},
- "@types/rx": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz",
- "integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=",
- "requires": {
- "@types/rx-core": "*",
- "@types/rx-core-binding": "*",
- "@types/rx-lite": "*",
- "@types/rx-lite-aggregates": "*",
- "@types/rx-lite-async": "*",
- "@types/rx-lite-backpressure": "*",
- "@types/rx-lite-coincidence": "*",
- "@types/rx-lite-experimental": "*",
- "@types/rx-lite-joinpatterns": "*",
- "@types/rx-lite-testing": "*",
- "@types/rx-lite-time": "*",
- "@types/rx-lite-virtualtime": "*"
- }
- },
- "@types/rx-core": {
- "version": "4.0.3",
- "resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz",
- "integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA="
- },
- "@types/rx-core-binding": {
- "version": "4.0.4",
- "resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz",
- "integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==",
- "requires": {
- "@types/rx-core": "*"
- }
- },
- "@types/rx-lite": {
- "version": "4.0.6",
- "resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.6.tgz",
- "integrity": "sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==",
- "requires": {
- "@types/rx-core": "*",
- "@types/rx-core-binding": "*"
- }
- },
- "@types/rx-lite-aggregates": {
- "version": "4.0.3",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz",
- "integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==",
- "requires": {
- "@types/rx-lite": "*"
- }
- },
- "@types/rx-lite-async": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz",
- "integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==",
- "requires": {
- "@types/rx-lite": "*"
- }
- },
- "@types/rx-lite-backpressure": {
- "version": "4.0.3",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz",
- "integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==",
- "requires": {
- "@types/rx-lite": "*"
- }
- },
- "@types/rx-lite-coincidence": {
- "version": "4.0.3",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz",
- "integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==",
- "requires": {
- "@types/rx-lite": "*"
- }
- },
- "@types/rx-lite-experimental": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz",
- "integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=",
- "requires": {
- "@types/rx-lite": "*"
- }
- },
- "@types/rx-lite-joinpatterns": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz",
- "integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=",
- "requires": {
- "@types/rx-lite": "*"
- }
- },
- "@types/rx-lite-testing": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz",
- "integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=",
- "requires": {
- "@types/rx-lite-virtualtime": "*"
- }
- },
- "@types/rx-lite-time": {
- "version": "4.0.3",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz",
- "integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==",
- "requires": {
- "@types/rx-lite": "*"
- }
- },
- "@types/rx-lite-virtualtime": {
- "version": "4.0.3",
- "resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz",
- "integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==",
- "requires": {
- "@types/rx-lite": "*"
- }
- },
"@types/secp256k1": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-3.5.0.tgz",
@@ -1774,11 +1618,6 @@
"integrity": "sha512-ZPHnXkzmGMfk+pHqAGzTSpA9CbsHmJLgkvOl5w52LZ0XTxB1ZIHWZzQ7lEtjTNWScBbsQekg8TjApMXkMe4nkw==",
"dev": true
},
- "@types/webassembly-js-api": {
- "version": "0.0.2",
- "resolved": "https://registry.npmjs.org/@types/webassembly-js-api/-/webassembly-js-api-0.0.2.tgz",
- "integrity": "sha512-htlxJRag6RUiMYUkS8Fjup+TMHO0VarpiF9MrqYaGJ0wXtIraQFz40rfA8VIeCiWy8sgpv3RLmigpgicG8fqGA=="
- },
"@types/xxhashjs": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@types/xxhashjs/-/xxhashjs-0.2.1.tgz",
@@ -4240,7 +4079,8 @@
"console-control-strings": {
"version": "1.1.0",
"resolved": "http://registry.npm.taobao.org/console-control-strings/download/console-control-strings-1.1.0.tgz",
- "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
+ "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
+ "optional": true
},
"constants-browserify": {
"version": "1.0.0",
@@ -4475,11 +4315,12 @@
"integrity": "sha1-QICG1AlVDCYxFVYZ6fp7ytw7mRs="
},
"d": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz",
- "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=",
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
+ "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
"requires": {
- "es5-ext": "^0.10.9"
+ "es5-ext": "^0.10.50",
+ "type": "^1.0.1"
}
},
"d3-array": {
@@ -9879,6 +9720,7 @@
"version": "2.3.5",
"resolved": "http://registry.npm.taobao.org/minipass/download/minipass-2.3.5.tgz",
"integrity": "sha1-ys6+SSAiSX9law8PUeJoKp7S2Eg=",
+ "optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -9887,7 +9729,8 @@
"yallist": {
"version": "3.0.3",
"resolved": "http://registry.npm.taobao.org/yallist/download/yallist-3.0.3.tgz",
- "integrity": "sha1-tLBJ4xS+VF486AIjbWzSLNkcPek="
+ "integrity": "sha1-tLBJ4xS+VF486AIjbWzSLNkcPek=",
+ "optional": true
}
}
},
@@ -11928,8 +11771,7 @@
"regenerator-runtime": {
"version": "0.13.2",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
- "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==",
- "dev": true
+ "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
},
"regenerator-transform": {
"version": "0.13.3",
@@ -13825,6 +13667,11 @@
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz",
"integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A=="
},
+ "type": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/type/-/type-1.0.1.tgz",
+ "integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw=="
+ },
"type-check": {
"version": "0.3.2",
"resolved": "http://registry.npm.taobao.org/type-check/download/type-check-0.3.2.tgz",
diff --git a/src/components/Active.js b/src/components/Active.js
index 6e5a9753..28771cc4 100755
--- a/src/components/Active.js
+++ b/src/components/Active.js
@@ -1,528 +1,541 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Text, View, Image, TouchableOpacity, RefreshControl, ScrollView } from 'react-native'
-import { Method } from '@polkadot/types'
-import { formatBalance } from '@polkadot/util'
-import { VictoryPie } from 'victory-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../util/Common'
-import polkadotAPI from '../util/polkadotAPI'
-import i18n from '../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Active extends Component {
- constructor(props) {
- super(props)
- this.state = {
- referendums: [],
- Actives_Nofixed: [],
- Actives_Nofixedvalue: [],
- Actives_Title: [],
- votingCountdown: 0,
- votingIndex: [],
- votingState: [],
- votingStateIndex: []
- }
- this.votingState = this.votingState.bind(this)
- this.Nay = this.Nay.bind(this)
- this.Aye = this.Aye.bind(this)
- this.NayNumber = this.NayNumber.bind(this)
- this.AyeNumber = this.AyeNumber.bind(this)
- }
-
- Nay(votingState) {
- let balance = 0
- for (let i = 0; i < votingState.msg.length; i++) {
- if (JSON.stringify(votingState.msg[i].vote) == '"0x00"') {
- balance = balance + Number(votingState.msg[i].balance)
- }
- }
- return balance
- }
-
- NayNumber(votingState) {
- let NayNumber = 0
- for (let i = 0; i < votingState.msg.length; i++) {
- if (JSON.stringify(votingState.msg[i].vote) == '"0x00"') {
- NayNumber = NayNumber + 1
- }
- }
- return NayNumber
- }
-
- Aye(votingState) {
- let balance = 0
- for (let i = 0; i < votingState.msg.length; i++) {
- if (JSON.stringify(votingState.msg[i].vote) == '"0xff"') {
- balance = balance + Number(votingState.msg[i].balance)
- }
- }
- return balance
- }
-
- AyeNumber(votingState) {
- let AyeNumber = 0
- for (let i = 0; i < votingState.msg.length; i++) {
- if (JSON.stringify(votingState.msg[i].vote) == '"0xff"') {
- AyeNumber = AyeNumber + 1
- }
- }
- return AyeNumber
- }
-
- votingState() {
- ;(async () => {
- this.state.votingState = []
- let ifNewIndex = false
- let l = 0
- for (let i = 0; i < this.state.votingIndex.length; i++) {
- await polkadotAPI.referendumVotesFor(this.state.votingIndex[i], result => {
- if (result[0] != null) {
- if (this.state.votingState[0] != null) {
- for (let k = 0; k < this.state.votingState.length; k++) {
- if (this.state.votingState[k][0].referendumId == result[0].referendumId) {
- this.state.votingState[k] = result
- l--
- break
- } else if (l == this.state.votingState.length) {
- ifNewIndex = true
- l = 0
- break
- }
- l++
- }
- if (ifNewIndex == true) {
- this.state.votingState.push(result)
- ifNewIndex = false
- }
- this.setState({})
- } else {
- this.state.votingState.push(result)
- }
- }
- })
- }
- })()
- }
-
- load() {
- ;(async () => {
- await polkadotAPI.bestNumber(bestNumber => {
- this.setState({ votingCountdown: bestNumber })
- })
-
- await polkadotAPI.referendums(result => {
- this.setState({
- referendums: [],
- Actives_Nofixed: [],
- Actives_Nofixedvalue: [],
- Actives_Title: [],
- votingIndex: [],
- votingState: []
- })
- let Actives_Title = [],
- Actives_Nofixedvalue = [],
- Actives_Nofixed = [],
- referendums = [],
- votingIndex = [],
- votingState = []
- result.map((item, index) => {
- let info = item.unwrapOr(null)
- if (info) {
- let { meta, method, section } = Method.findFunction(info.proposal.callIndex)
- let have = 0
- Actives_Title.push({ section: section, method: method })
- Actives_Nofixedvalue.push(info.proposal.args)
- Actives_Nofixed.push(meta.args)
- referendums.push(info)
- votingIndex.push(info.index)
- for (let i = 0; i < votingState.length; i++) {
- if (votingState[i].index == index) {
- have = 1
- }
- }
- if (have == 0) {
- votingState.push({ index: info.index, msg: [] })
- }
- }
- this.setState({
- Actives_Title,
- Actives_Nofixedvalue,
- Actives_Nofixed,
- referendums,
- votingIndex,
- votingState
- })(async () => {
- const index = info.index
- await polkadotAPI.referendumVotesFor(index, result => {
- this.props.rootStore.stateStore.have = 0
- for (let i = 0; i < this.state.votingState.length; i++) {
- if (this.state.votingState[i].index == index) {
- this.props.rootStore.stateStore.have = 1
- this.state.votingState[i].msg = result
- }
- }
- })
- })()
- })
- })
- })()
- }
-
- componentWillMount() {
- this.load()
- }
-
- refresh() {
- this.setState({
- isrefresh: true
- })
- this.load()
- setTimeout(() => {
- this.setState({
- isrefresh: false
- })
- }, 2000)
- }
-
- render() {
- return (
-
-
- }
- >
- {this.state.referendums[0] == null ? (
-
- {i18n.t('Democracy.noReferendums')}
-
- ) : (
- this.state.referendums.map((item, index) => {
- return (
-
-
-
-
-
- {this.state.Actives_Title[index].section + '.' + this.state.Actives_Title[index].method}
-
-
-
-
- {Number(item.end) - Number(this.state.votingCountdown) - 1}
-
- {i18n.t('Democracy.blocksEnd')}
-
- {this.state.Actives_Nofixed[index].map((itemNo, indexNo) => {
- return (
-
-
- {itemNo.name + ' : ' + itemNo.type}
-
-
-
- {String(this.state.Actives_Nofixedvalue[index][indexNo])}
-
-
-
- )
- })}
-
-
-
- {'#' + item.index}
-
-
-
-
-
- {this.Aye(this.state.votingState[index]) == 0 ? (
-
- ) : (
-
-
-
- {i18n.t('Democracy.Threshold')}
- {': ' + item.threshold}
-
-
-
-
-
-
-
-
-
- {i18n.t('Democracy.Aye')}
- {' ' + formatBalance(this.Aye(this.state.votingState[index]))}
-
-
- {(
- (this.Aye(this.state.votingState[index]) /
- (this.Aye(this.state.votingState[index]) + this.Nay(this.state.votingState[index]))) *
- 100
- ).toFixed(2) + '%'}
-
-
- {'(' + this.AyeNumber(this.state.votingState[index]) + ')'}
-
-
-
-
-
- {i18n.t('Democracy.Nay')}
- {' ' + formatBalance(this.Nay(this.state.votingState[index]))}
-
-
- {(
- (this.Nay(this.state.votingState[index]) /
- (this.Aye(this.state.votingState[index]) + this.Nay(this.state.votingState[index]))) *
- 100
- ).toFixed(2) + '%'}
-
-
- {'(' + this.NayNumber(this.state.votingState[index]) + ')'}
-
-
-
-
- )}
-
- {/* Nay or Aye */}
-
-
- {
- this.props.p.navigation.navigate('NayorAye', {
- choose: 'Nay',
- index: item.index
- })
- }}
- >
- {i18n.t('Democracy.Nay')}
-
- {
- this.props.p.navigation.navigate('NayorAye', {
- choose: 'Aye',
- index: item.index
- })
- }}
- >
- {i18n.t('Democracy.Aye')}
-
-
-
-
-
- )
- })
- )}
-
-
- )
- }
-}
-export default Active
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Text, View, Image, TouchableOpacity, RefreshControl, ScrollView } from 'react-native'
+import { Method } from '@polkadot/types'
+import { formatBalance } from '@polkadot/util'
+import { VictoryPie } from 'victory-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight } from '../util/Common'
+import polkadotAPI from '../util/polkadotAPI'
+import i18n from '../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Active extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ referendums: [],
+ Actives_Nofixed: [],
+ Actives_Nofixedvalue: [],
+ Actives_Title: [],
+ votingCountdown: 0,
+ votingIndex: [],
+ votingState: [],
+ votingStateIndex: []
+ }
+ this.votingState = this.votingState.bind(this)
+ this.Nay = this.Nay.bind(this)
+ this.Aye = this.Aye.bind(this)
+ this.NayNumber = this.NayNumber.bind(this)
+ this.AyeNumber = this.AyeNumber.bind(this)
+ }
+
+ /**
+ * @description 根据投票信息获取 Nay balance | Get Nay balance based on the voting information.
+ * @param {Object} votingState 投票信息 | voting information.
+ */
+ Nay(votingState) {
+ let balance = 0
+ for (let i = 0; i < votingState.msg.length; i++) {
+ if (JSON.stringify(votingState.msg[i].vote) == '"0x00"') {
+ balance = balance + Number(votingState.msg[i].balance)
+ }
+ }
+ return balance
+ }
+
+ /**
+ * @description 根据投票信息获取 NayNumber | Get NayNumber based on the voting information.
+ * @param {Object} votingState 投票信息 | voting information.
+ */
+ NayNumber(votingState) {
+ let NayNumber = 0
+ for (let i = 0; i < votingState.msg.length; i++) {
+ if (JSON.stringify(votingState.msg[i].vote) == '"0x00"') {
+ NayNumber = NayNumber + 1
+ }
+ }
+ return NayNumber
+ }
+
+ /**
+ * @description 根据投票信息获取 Aye balance | Get Aye balance based on the voting information.
+ * @param {Object} votingState 投票信息 | voting information.
+ */
+ Aye(votingState) {
+ let balance = 0
+ for (let i = 0; i < votingState.msg.length; i++) {
+ if (JSON.stringify(votingState.msg[i].vote) == '"0xff"') {
+ balance = balance + Number(votingState.msg[i].balance)
+ }
+ }
+ return balance
+ }
+
+ /**
+ * @description 根据投票信息获取AyeNumber | Get AyeNumber based on the voting information.
+ * @param {Object} votingState 投票信息 | voting information.
+ */
+ AyeNumber(votingState) {
+ let AyeNumber = 0
+ for (let i = 0; i < votingState.msg.length; i++) {
+ if (JSON.stringify(votingState.msg[i].vote) == '"0xff"') {
+ AyeNumber = AyeNumber + 1
+ }
+ }
+ return AyeNumber
+ }
+
+ /**
+ * @description 获取所有的投票信息 | Get all the voting information.
+ */
+ votingState() {
+ ;(async () => {
+ this.state.votingState = []
+ let ifNewIndex = false
+ let l = 0
+ for (let i = 0; i < this.state.votingIndex.length; i++) {
+ await polkadotAPI.referendumVotesFor(this.state.votingIndex[i], result => {
+ if (result[0] != null) {
+ if (this.state.votingState[0] != null) {
+ for (let k = 0; k < this.state.votingState.length; k++) {
+ if (this.state.votingState[k][0].referendumId == result[0].referendumId) {
+ this.state.votingState[k] = result
+ l--
+ break
+ } else if (l == this.state.votingState.length) {
+ ifNewIndex = true
+ l = 0
+ break
+ }
+ l++
+ }
+ if (ifNewIndex == true) {
+ this.state.votingState.push(result)
+ ifNewIndex = false
+ }
+ this.setState({})
+ } else {
+ this.state.votingState.push(result)
+ }
+ }
+ })
+ }
+ })()
+ }
+
+ /**
+ * @description 初始化页面 加载相关数据 | Initializes page load related data.
+ */
+ load() {
+ ;(async () => {
+ await polkadotAPI.bestNumber(bestNumber => {
+ this.setState({ votingCountdown: bestNumber })
+ })
+ await polkadotAPI.referendums(result => {
+ this.setState({
+ referendums: [],
+ Actives_Nofixed: [],
+ Actives_Nofixedvalue: [],
+ Actives_Title: [],
+ votingIndex: [],
+ votingState: []
+ })
+ result.map((item, index) => {
+ let info = item.unwrapOr(null)
+ try {
+ if (info.proposal.args.proposal) {
+ info = info.proposal.args
+ }
+ } catch (e) {}
+ if (info) {
+ let { meta, method, section } = Method.findFunction(info.proposal.callIndex)
+ let have = 0
+ this.state.Actives_Title.push({ section: section, method: method })
+ this.state.Actives_Nofixedvalue.push(info.proposal.args)
+ this.state.Actives_Nofixed.push(meta.args)
+ this.state.referendums.push(info)
+ this.state.votingIndex.push(info.index)
+ if (have == 0) {
+ this.state.votingState.push({ index: info.index, msg: [] })
+ }
+ const index = info.index
+ polkadotAPI.referendumVotesFor(index, result => {
+ this.props.rootStore.stateStore.have = 0
+ for (let i = 0; i < this.state.votingState.length; i++) {
+ if (this.state.votingState[i].index == index) {
+ this.props.rootStore.stateStore.have = 1
+ this.state.votingState[i].msg = result
+ this.setState({})
+ }
+ }
+ })
+ }
+ })
+ })
+ })()
+ }
+
+ componentWillMount() {
+ this.load()
+ }
+
+ /**
+ * @description 刷新 | Refresh.
+ */
+ refresh() {
+ this.setState({
+ isrefresh: true
+ })
+ this.load()
+ setTimeout(() => {
+ this.setState({
+ isrefresh: false
+ })
+ }, 2000)
+ }
+
+ render() {
+ return (
+
+
+ }
+ >
+ {this.state.referendums[0] == null || this.props.num == 0 ? (
+
+ {i18n.t('Democracy.noReferendums')}
+
+ ) : (
+ this.state.referendums.map((item, index) => {
+ return (
+
+
+
+
+
+ {this.state.Actives_Title[index].section + '.' + this.state.Actives_Title[index].method}
+
+
+
+
+ {Number(item.end) - Number(this.state.votingCountdown) - 1}
+
+ {i18n.t('Democracy.blocksEnd')}
+
+ {this.state.Actives_Nofixed[index].map((itemNo, indexNo) => {
+ return (
+
+
+ {itemNo.name + ' : ' + itemNo.type}
+
+
+
+ {String(this.state.Actives_Nofixedvalue[index][indexNo])}
+
+
+
+ )
+ })}
+
+
+
+ {'#' + item.index}
+
+
+
+
+
+ {this.Aye(this.state.votingState[index]) == 0 &&
+ this.NayNumber(this.state.votingState[index]) == 0 ? (
+
+ ) : (
+
+
+
+ {i18n.t('Democracy.Threshold')}
+ {': ' + item.threshold}
+
+
+
+
+
+
+
+
+
+ {i18n.t('Democracy.Aye')}
+ {' ' + formatBalance(this.Aye(this.state.votingState[index]))}
+
+
+ {(
+ (this.Aye(this.state.votingState[index]) /
+ (this.Aye(this.state.votingState[index]) + this.Nay(this.state.votingState[index]))) *
+ 100
+ ).toFixed(2) + '%'}
+
+
+ {'(' + this.AyeNumber(this.state.votingState[index]) + ')'}
+
+
+
+
+
+ {i18n.t('Democracy.Nay')}
+ {' ' + formatBalance(this.Nay(this.state.votingState[index]))}
+
+
+ {(
+ (this.Nay(this.state.votingState[index]) /
+ (this.Aye(this.state.votingState[index]) + this.Nay(this.state.votingState[index]))) *
+ 100
+ ).toFixed(2) + '%'}
+
+
+ {'(' + this.NayNumber(this.state.votingState[index]) + ')'}
+
+
+
+
+ )}
+
+ {/* Nay or Aye */}
+
+
+ {
+ this.props.p.navigation.navigate('Vote', {
+ choose: 'Nay',
+ index: item.index
+ })
+ }}
+ >
+ {i18n.t('Democracy.Nay')}
+
+ {
+ this.props.p.navigation.navigate('Vote', {
+ choose: 'Aye',
+ index: item.index
+ })
+ }}
+ >
+ {i18n.t('Democracy.Aye')}
+
+
+
+
+
+ )
+ })
+ )}
+
+
+ )
+ }
+}
+export default Active
diff --git a/src/components/CoinRow.js b/src/components/CoinRow.js
index 30e9711c..fa5853d2 100755
--- a/src/components/CoinRow.js
+++ b/src/components/CoinRow.js
@@ -1,71 +1,72 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Image, View, TouchableOpacity, Text } from 'react-native'
-import moment from 'moment/moment'
-import { formatBalance } from '@polkadot/util'
-import { ScreenWidth } from '../util/Common'
-
-export default class CoinRow extends Component {
- render() {
- const { item, index, navigation } = this.props
- return (
- {
- navigation.navigate('Transfer_details', { data: item })
- }}
- style={{
- alignItems: 'center',
- flexDirection: 'row',
- height: 64,
- borderBottomWidth: 1,
- borderColor: '#F0F0F0'
- }}
- >
-
-
- {item.tx_address}
-
-
- {moment(item.tx_timestamp).format('DD/MM/YYYY HH:mm:ss')}
-
-
- {/* 余额 | Balance */}
-
- {item.tx_type == 'Receive'
- ? `+ ${formatBalance(String(item.tx_value))}`
- : `- ${formatBalance(String(item.tx_value))}`}
-
-
-
- )
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Image, View, TouchableOpacity, Text } from 'react-native'
+import moment from 'moment/moment'
+import { formatBalance } from '@polkadot/util'
+import { ScreenWidth } from '../util/Common'
+
+export default class CoinRow extends Component {
+ render() {
+ const { item, index, navigation } = this.props
+ return (
+ {
+ navigation.navigate('Transfer_details', { data: item })
+ }}
+ style={{
+ alignItems: 'center',
+ flexDirection: 'row',
+ height: 64,
+ borderBottomWidth: 1,
+ borderColor: '#F0F0F0'
+ }}
+ >
+
+
+ {item.tx_address}
+
+
+ {moment(item.tx_timestamp).format('DD/MM/YYYY HH:mm:ss')}
+
+
+ {/* 余额 | Balance */}
+
+ {item.tx_type == 'Receive'
+ ? `+ ${formatBalance(String(item.tx_value))}`
+ : `- ${formatBalance(String(item.tx_value))}`}
+
+
+
+ )
+ }
+}
diff --git a/src/components/Header.js b/src/components/Header.js
index 38fce0e6..22c9b5f8 100755
--- a/src/components/Header.js
+++ b/src/components/Header.js
@@ -1,78 +1,87 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Image, View, TouchableOpacity, Text } from 'react-native'
-import { ScreenWidth } from '../util/Common'
-
-export default class Header extends Component {
- back() {
- this.props.navigation.goBack()
- }
-
- render() {
- const { title, rightIcon, rightPress, backPress } = this.props
- const theme = this.props.theme || 'light'
- return (
-
-
- {/* */}
-
- {/* */}
-
-
- {title}
-
- {rightIcon ? (
- {
- rightPress()
- }}
- >
-
-
- ) : (
-
-
-
- )}
-
- )
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Image, View, TouchableOpacity, Text } from 'react-native'
+import { ScreenWidth } from '../util/Common'
+
+export default class Header extends Component {
+ /**
+ * @description 返回上一页 | Go back to the previous page.
+ */
+ back() {
+ this.props.navigation.goBack()
+ }
+
+ render() {
+ const { title, rightIcon, rightPress, backPress } = this.props
+ const theme = this.props.theme || 'light'
+ return (
+
+
+ {/* */}
+
+ {/* */}
+
+
+ {title}
+
+ {rightIcon ? (
+ {
+ rightPress()
+ }}
+ activeOpacity={0.7}
+ >
+
+
+ ) : (
+
+
+
+ )}
+
+ )
+ }
+}
diff --git a/src/components/Loading.js b/src/components/Loading.js
index 10e41c56..25e1137f 100755
--- a/src/components/Loading.js
+++ b/src/components/Loading.js
@@ -1,105 +1,112 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React from 'react'
-import { ActivityIndicator, StyleSheet, Text, View, Dimensions } from 'react-native'
-import i18n from '../locales/i18n'
-
-const { width } = Dimensions.get('window')
-const { height } = Dimensions.get('window')
-
-const styles = StyleSheet.create({
- loading: {
- backgroundColor: '#10101099',
- height: 80,
- width: 100,
- borderRadius: 10,
- justifyContent: 'center',
- alignItems: 'center',
- position: 'absolute',
- top: (height - 80) / 2,
- left: (width - 100) / 2
- },
-
- loadingTitle: {
- marginTop: 10,
- fontSize: 14,
- color: 'white'
- }
-})
-export default class Loading extends React.Component {
- constructor(props) {
- super(props)
- this.minShowingTime = 200
- this.state = {
- isLoading: false,
- setIsLoading: isLoading => {
- if (isLoading != this.state.isLoading) {
- const curTimeLong = new Date().getTime()
- if (isLoading) {
- this.startTime = curTimeLong
- this.setState({
- isLoading
- })
- } else {
- const hasShowingTimeLong = curTimeLong - this.startTime
- if (hasShowingTimeLong < this.minShowingTime) {
- setTimeout(() => {
- this.setState({
- isLoading
- })
- }, this.minShowingTime - hasShowingTimeLong)
- } else {
- this.setState({
- isLoading
- })
- }
- }
- }
- }
- }
- }
-
- showLoading = () => {
- this.state.setIsLoading(true)
- }
-
- dismissLoading = () => {
- this.state.setIsLoading(false)
- }
-
- render() {
- if (!this.state.isLoading) {
- return null
- }
- return (
-
-
-
-
- {i18n.t('TAB.loading')}
- ...
-
-
-
- )
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React from 'react'
+import { ActivityIndicator, StyleSheet, Text, View, Dimensions } from 'react-native'
+import i18n from '../locales/i18n'
+
+const { width } = Dimensions.get('window')
+const { height } = Dimensions.get('window')
+
+const styles = StyleSheet.create({
+ loading: {
+ backgroundColor: '#10101099',
+ height: 80,
+ width: 100,
+ borderRadius: 10,
+ justifyContent: 'center',
+ alignItems: 'center',
+ position: 'absolute',
+ top: (height - 80) / 2,
+ left: (width - 100) / 2
+ },
+
+ loadingTitle: {
+ marginTop: 10,
+ fontSize: 14,
+ color: 'white'
+ }
+})
+export default class Loading extends React.Component {
+ constructor(props) {
+ super(props)
+ this.minShowingTime = 200
+ this.state = {
+ isLoading: false,
+ setIsLoading: isLoading => {
+ if (isLoading != this.state.isLoading) {
+ const curTimeLong = new Date().getTime()
+ if (isLoading) {
+ this.startTime = curTimeLong
+ this.setState({
+ isLoading
+ })
+ } else {
+ const hasShowingTimeLong = curTimeLong - this.startTime
+ if (hasShowingTimeLong < this.minShowingTime) {
+ setTimeout(() => {
+ this.setState({
+ isLoading
+ })
+ }, this.minShowingTime - hasShowingTimeLong)
+ } else {
+ this.setState({
+ isLoading
+ })
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @description 展示loading框 | Show the loading frame.
+ */
+ showLoading = () => {
+ this.state.setIsLoading(true)
+ }
+
+ /**
+ * @description 隐藏loading框 | Hide the loading frame.
+ *
+ */
+ dismissLoading = () => {
+ this.state.setIsLoading(false)
+ }
+
+ render() {
+ if (!this.state.isLoading) {
+ return null
+ }
+ return (
+
+
+
+
+ {i18n.t('TAB.loading')}
+ ...
+
+
+
+ )
+ }
+}
diff --git a/src/components/LoadingUtil.js b/src/components/LoadingUtil.js
index 992cbd8f..bc86c7d7 100755
--- a/src/components/LoadingUtil.js
+++ b/src/components/LoadingUtil.js
@@ -1,28 +1,35 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-const LoadingUtil = {
- showLoading(timeOut = 30000) {
- global.LoadingTip = true
- global.mLoadingComponentRef && global.mLoadingComponentRef.showLoading()
- this.timerLoading = setTimeout(() => {
- this.dismissLoading()
- }, timeOut)
- },
- dismissLoading() {
- global.LoadingTip = false
- global.mLoadingComponentRef && global.mLoadingComponentRef.dismissLoading()
- this.timerLoading && clearTimeout(this.timerLoading)
- }
-}
-
-export default LoadingUtil
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+const LoadingUtil = {
+ /**
+ * @description 展示loading框 | Show the loading frame.
+ * @param {Number} timeOut 超时时间 默认3000 (3s) | Timeout default 3000 (3s).
+ */
+ showLoading(timeOut = 30000) {
+ global.LoadingTip = true
+ global.mLoadingComponentRef && global.mLoadingComponentRef.showLoading()
+ this.timerLoading = setTimeout(() => {
+ this.dismissLoading()
+ }, timeOut)
+ },
+ /**
+ * @description 隐藏loading框 | Hide the loading frame.
+ */
+ dismissLoading() {
+ global.LoadingTip = false
+ global.mLoadingComponentRef && global.mLoadingComponentRef.dismissLoading()
+ this.timerLoading && clearTimeout(this.timerLoading)
+ }
+}
+
+export default LoadingUtil
diff --git a/src/components/ProposalsRow.js b/src/components/ProposalsRow.js
index 76917abb..4f9dab88 100755
--- a/src/components/ProposalsRow.js
+++ b/src/components/ProposalsRow.js
@@ -1,142 +1,167 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Text, View, Image } from 'react-native'
-import { ScreenWidth, ScreenHeight } from '../util/Common'
-import i18n from '../locales/i18n'
-
-export default class ProposalsRow extends Component {
- render() {
- const { publicProps, Actives_Nofixed, Actives_Title, Actives_Nofixedvalue, launchCountdown, balances } = this.props
- return publicProps.map((item, index) => (
-
-
-
-
-
- {`${Actives_Title[index].section}.${Actives_Title[index].method}`}
-
-
-
- {launchCountdown + 9 * index}
- {i18n.t('Democracy.blocksLaunch')}
-
- {Actives_Nofixed[index].map((itemNo, indexNo) => (
-
- {`${itemNo.name} : ${itemNo.type}`}
-
-
- {String(Actives_Nofixedvalue[index][indexNo])}
-
-
-
- ))}
-
-
- {`#${item[0]}`}
-
-
- {/* 虚线 | Dotted line */}
-
-
- {/* 确定个数 | Determine the number */}
-
-
- {i18n.t('Democracy.depositors')}
-
-
- {String(item[2])}
-
-
-
-
- {i18n.t('Democracy.balance')}
-
-
- {String(balances[index])}
-
-
-
-
-
-
-
-
- ))
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Text, View, Image } from 'react-native'
+import { formatBalance } from '@polkadot/util'
+import { ScreenWidth, ScreenHeight } from '../util/Common'
+import i18n from '../locales/i18n'
+
+export default class ProposalsRow extends Component {
+ render() {
+ const { publicProps, Actives_Nofixed, Actives_Title, Actives_Nofixedvalue, launchCountdown, balances } = this.props
+ return publicProps.map((item, index) => (
+
+
+
+
+
+ {`${Actives_Title[index].section}.${Actives_Title[index].method}`}
+
+
+
+ {launchCountdown + 9 * index}
+ {i18n.t('Democracy.blocksLaunch')}
+
+ {Actives_Nofixed[index].map((itemNo, indexNo) => (
+
+ {`${itemNo.name} : ${itemNo.type}`}
+
+
+ {String(Actives_Nofixedvalue[index][indexNo]) || ''}
+
+
+
+ ))}
+
+
+ {`#${item[0]}`}
+
+
+ {/* 虚线 | Dotted line */}
+
+
+ {/* 确定个数 | Determine the number */}
+
+
+ {i18n.t('Democracy.depositors')}
+
+
+ {String(item[2] || 0)}
+
+
+
+
+ {i18n.t('Democracy.balance')}
+
+
+ {String(formatBalance(balances[index] || 0))}
+
+
+
+
+
+
+
+
+ ))
+ }
+}
diff --git a/src/components/RNKeyboardAvoidView.js b/src/components/RNKeyboardAvoidView.js
index 4b095c7d..df2a8fa4 100755
--- a/src/components/RNKeyboardAvoidView.js
+++ b/src/components/RNKeyboardAvoidView.js
@@ -1,26 +1,26 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { KeyboardAvoidingView, ScrollView, Platform } from 'react-native'
-
-export default class RNKeyboardAvoidView extends Component {
- render() {
- return Platform.OS == 'ios' ? (
-
- {this.props.children}
-
- ) : (
- {this.props.children}
- )
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { KeyboardAvoidingView, ScrollView, Platform } from 'react-native'
+
+export default class RNKeyboardAvoidView extends Component {
+ render() {
+ return Platform.OS == 'ios' ? (
+
+ {this.props.children}
+
+ ) : (
+ {this.props.children}
+ )
+ }
+}
diff --git a/src/components/RNPicker.js b/src/components/RNPicker.js
index 0dad1746..5f45c6ce 100755
--- a/src/components/RNPicker.js
+++ b/src/components/RNPicker.js
@@ -1,132 +1,140 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Platform, Picker, Text, ActionSheetIOS, TouchableOpacity, Image } from 'react-native'
-import i18n from '../locales/i18n'
-
-const defaultData = [
- {
- title: 'femto',
- value: 'femto'
- },
- {
- title: 'pico',
- value: 'pico'
- },
- {
- title: 'nano',
- value: 'nano'
- },
- {
- title: 'micro',
- value: 'micro'
- },
- {
- title: 'milli',
- value: 'milli'
- },
- {
- title: 'DOT',
- value: 'DOT'
- },
- {
- title: 'Kilo',
- value: 'Kilo'
- },
- {
- title: 'Mega',
- value: 'Mega'
- },
- {
- title: 'Giga',
- value: 'Giga'
- },
- {
- title: 'Tera',
- value: 'Tera'
- },
- {
- title: 'Peta',
- value: 'Peta'
- },
- {
- title: 'Exa',
- value: 'Exa'
- },
- {
- title: 'Zeta',
- value: 'Zeta'
- },
- {
- title: 'Yotta',
- value: 'Yotta'
- }
-]
-export default class RNPicker extends Component {
- sheet(data) {
- let paramas = []
- const _this = this
- data.map(v => {
- paramas.push(v.label ? i18n.t(v.label) : v.title)
- })
- paramas.push(i18n.t('TAB.Cancel'))
- ActionSheetIOS.showActionSheetWithOptions(
- {
- options: paramas,
- cancelButtonIndex: paramas.length - 1
- // destructiveButtonIndex: 0
- },
- function(index) {
- if (index != paramas.length) {
- _this.props.onValueChange(data[index].value)
- }
- }
- )
- }
-
- render() {
- const { style, selectedValue, onValueChange } = this.props
- const data = this.props.data || defaultData
- let showLable = ''
- data.map(v => {
- if (v.value == selectedValue) {
- showLable = v.label ? i18n.t(v.label) : v.title
- }
- })
- return Platform.OS == 'ios' ? (
-
- {showLable}
-
-
- ) : (
-
- {data &&
- data.map((v, i) => )}
-
- )
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Platform, Picker, Text, ActionSheetIOS, TouchableOpacity, Image } from 'react-native'
+import i18n from '../locales/i18n'
+import { doubleClick } from '../util/Common'
+
+const defaultData = [
+ {
+ title: 'femto',
+ value: 'femto'
+ },
+ {
+ title: 'pico',
+ value: 'pico'
+ },
+ {
+ title: 'nano',
+ value: 'nano'
+ },
+ {
+ title: 'micro',
+ value: 'micro'
+ },
+ {
+ title: 'milli',
+ value: 'milli'
+ },
+ {
+ title: 'DOT',
+ value: 'DOT'
+ },
+ {
+ title: 'Kilo',
+ value: 'Kilo'
+ },
+ {
+ title: 'Mega',
+ value: 'Mega'
+ },
+ {
+ title: 'Giga',
+ value: 'Giga'
+ },
+ {
+ title: 'Tera',
+ value: 'Tera'
+ },
+ {
+ title: 'Peta',
+ value: 'Peta'
+ },
+ {
+ title: 'Exa',
+ value: 'Exa'
+ },
+ {
+ title: 'Zeta',
+ value: 'Zeta'
+ },
+ {
+ title: 'Yotta',
+ value: 'Yotta'
+ }
+]
+export default class RNPicker extends Component {
+ /**
+ * @description IOS ActionSheet
+ * @param {Array} data 要展示的选项 | The options to show.
+ */
+ sheet(data) {
+ let paramas = []
+ const _this = this
+ data.map(v => {
+ paramas.push(v.label ? i18n.t(v.label) : v.title)
+ })
+ paramas.push(i18n.t('TAB.Cancel'))
+ ActionSheetIOS.showActionSheetWithOptions(
+ {
+ options: paramas,
+ cancelButtonIndex: paramas.length - 1
+ // destructiveButtonIndex: 0
+ },
+ function(index) {
+ if (index != paramas.length) {
+ _this.props.onValueChange(data[index].value)
+ }
+ }
+ )
+ }
+
+ render() {
+ const { style, selectedValue, onValueChange } = this.props
+ const data = this.props.data || defaultData
+ let showLable = ''
+ data.map(v => {
+ if (v.value == selectedValue) {
+ showLable = v.label ? i18n.t(v.label) : v.title
+ }
+ })
+ return Platform.OS == 'ios' ? (
+ {
+ doubleClick(this.sheet.bind(this, data))
+ }}
+ activeOpacity={0.7}
+ style={[
+ style,
+ {
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ paddingLeft: 10,
+ flexDirection: 'row'
+ }
+ ]}
+ >
+ {showLable}
+
+
+ ) : (
+
+ {data &&
+ data.map((v, i) => )}
+
+ )
+ }
+}
diff --git a/src/components/bottom.js b/src/components/bottom.js
index 75afc370..b2050d1a 100755
--- a/src/components/bottom.js
+++ b/src/components/bottom.js
@@ -1,26 +1,26 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Image, Dimensions } from 'react-native'
-
-const ScreenHeight = Dimensions.get('screen').height
-export default class TabBarItem extends Component {
- render() {
- return (
-
- )
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Image, Dimensions } from 'react-native'
+
+const ScreenHeight = Dimensions.get('screen').height
+export default class TabBarItem extends Component {
+ render() {
+ return (
+
+ )
+ }
+}
diff --git a/src/locales/en-US/Assets/index.js b/src/locales/en-US/Assets/index.js
index b5644060..150d8972 100755
--- a/src/locales/en-US/Assets/index.js
+++ b/src/locales/en-US/Assets/index.js
@@ -1,96 +1,96 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-21 20:09:00
- */
-export default {
- Alexander: 'Alexander TestNet',
- Receive: 'Receive',
- Account: 'Account',
- AssetsList: 'Assets list',
- Scan: 'Scan',
- Menu: 'Menu',
- CreateAccount: 'Create Account',
- // Create_Account 页面
- balance: 'balance',
- Createfrom: 'Create from mnemonic,seed or import keystore',
- WordMnemonic12: '12 Word Mnemonic',
- WordMnemonic24: '24 Word Mnemonic',
- RawSeed: 'Raw Seed',
- ImportKeystore: 'import keystore',
- NameTheAccount: 'name the account',
- Password: 'encrypt it using a password',
- EnterName: 'Please enter your name',
- EnterPassword: 'Please enter your password',
- EnterPassword_d: 'Please confirm the password',
- CheckPassword: 'The two passwords do not match. Please re-enter them',
- ExistingAddress: 'The address already exists!',
- // Backup_Account 页面
- Warning: 'Warning',
- BeforeSafe: 'Before you continue,make sure you have properly backed up your seed in a safe place as',
- Restore: 'It is needed ro restore your account',
- // camera 页面
- QRCodeTip: 'Put the QR code into the box you can scan it automatically',
- Flashlight: 'Click on/off the flashlight',
- // coin_details 页面
- AssetsOption: 'Assets change record, Unit(xxx)',
- AssetsOption_new: 'Assets change record, Unit',
- // make_transfer 页面
- Transfer: 'Transfer DOT',
- TransferFailed: 'Transfer Failed.',
- TransferSuccess: 'Transfer Success.',
- SubmitTransaction: 'Submit Transaction',
- recipientAddress: 'to the recipient address',
- sendOf: 'send a value of ',
- send: 'Send',
- PleaseEnterAddress: 'Please enter address',
- creationFee: 'creationFee',
- existentialDeposit: 'existentialDeposit',
- transactionBaseFee: 'transactionBaseFee',
- transactionByteFee: 'transactionByteFee',
- transferFee: 'transferFee',
- MakeTransfer: 'Make Transfer',
- // Transfer 页面
- enterValue: 'Please enter Send a value',
- enterInformation: 'Please enter the correct information.',
- // Transfer_details 页面
- Details: 'Details',
- Successed: 'Successed',
- Balance: 'Balance',
- Fees: 'Fees',
- To: 'To',
- From: 'From',
- Block: 'Block',
- BlockHash: 'BlockHash',
- // make_transfer 页面
- TransferDOT: 'Transfer DOT',
- calling: 'calling',
- withIndex: 'with an index of ',
- SignAndSubmit: 'Sign and Submit',
- // Receive
- CopyAddress: 'Copy address',
- // MnemonicWord.js
- MWTitle: 'Backup prom',
- MWTip1: 'Getting a mnemonic equals ownership of a wallet asset',
- MWTip2: 'Backup mnemonic',
- MWTip3: 'Use paper and pen to correctly copy mnemonics',
- MWTip4: 'If your phone is lost, stolen or damaged, the mnemonic will restore your assets.',
- MWTip5: 'Offline storage',
- MWTip6: 'Keep it safe to a safe place on the isolated network',
- MWTip7:
- 'Do not share and store mnemonics in a networked environment, such as emails, photo albums, social applications',
- MWTip9: 'Do not take screenshots',
- MWTip10: 'Do not screen capture and storage, which may be collected by third-party malware, resulting in asset loss',
- MWTip11: 'cancel',
- MWTip12: 'Got it',
- MWTip13: 'Please accurately copy and safely backup the mnemonic',
- MWTip14: 'Please click on mnemonics in order to confirm that you have backed up correctly',
- MWTip15: 'The order of the mnemonic is incorrect,please proofread'
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+export default {
+ Alexander: 'Alexander TestNet',
+ Receive: 'Receive',
+ Account: 'Account',
+ AssetsList: 'Assets list',
+ Scan: 'Scan',
+ Menu: 'Menu',
+ CreateAccount: 'Create Account',
+ // Create_Account 页面
+ balance: 'balance',
+ Createfrom: 'Create from mnemonic,seed or import keystore',
+ WordMnemonic12: '12 Word Mnemonic',
+ WordMnemonic24: '24 Word Mnemonic',
+ RawSeed: 'Raw Seed',
+ ImportKeystore: 'import keystore',
+ NameTheAccount: 'name the account',
+ Password: 'encrypt it using a password',
+ EnterName: 'Please enter your name',
+ EnterPassword: 'Please enter your password',
+ EnterPassword_d: 'Please confirm the password',
+ CheckPassword: 'The two passwords do not match. Please re-enter them',
+ ExistingAddress: 'The address already exists!',
+ // Backup_Account 页面
+ Warning: 'Warning',
+ BeforeSafe: 'Before you continue,make sure you have properly backed up your seed in a safe place as',
+ Restore: 'It is needed ro restore your account',
+ // camera 页面
+ QRCodeTip: 'Put the QR code into the box you can scan it automatically',
+ Flashlight: 'Click on/off the flashlight',
+ // coin_details 页面
+ AssetsOption: 'Assets change record, Unit(xxx)',
+ AssetsOption_new: 'Assets change record, Unit',
+ // make_transfer 页面
+ Transfer: 'Transfer DOT',
+ TransferFailed: 'Transfer Failed.',
+ TransferSuccess: 'Transfer Success.',
+ SubmitTransaction: 'Submit Transaction',
+ recipientAddress: 'to the recipient address',
+ sendOf: 'send a value of ',
+ send: 'Send',
+ PleaseEnterAddress: 'Please enter address',
+ creationFee: 'creationFee',
+ existentialDeposit: 'existentialDeposit',
+ transactionBaseFee: 'transactionBaseFee',
+ transactionByteFee: 'transactionByteFee',
+ transferFee: 'transferFee',
+ MakeTransfer: 'Make Transfer',
+ // Transfer 页面
+ enterValue: 'Please enter Send a value',
+ enterInformation: 'Please enter the correct information.',
+ // Transfer_details 页面
+ Details: 'Details',
+ Successed: 'Successed',
+ Balance: 'Balance',
+ Fees: 'Fees',
+ To: 'To',
+ From: 'From',
+ Block: 'Block',
+ BlockHash: 'BlockHash',
+ // make_transfer 页面
+ TransferDOT: 'Transfer DOT',
+ calling: 'calling',
+ withIndex: 'with an index of ',
+ SignAndSubmit: 'Sign and Submit',
+ // Receive
+ CopyAddress: 'Copy address',
+ // MnemonicWord.js
+ MWTitle: 'Backup prom',
+ MWTip1: 'Getting a mnemonic equals ownership of a wallet asset',
+ MWTip2: 'Backup mnemonic',
+ MWTip3: 'Use paper and pen to correctly copy mnemonics',
+ MWTip4: 'If your phone is lost, stolen or damaged, the mnemonic will restore your assets.',
+ MWTip5: 'Offline storage',
+ MWTip6: 'Keep it safe to a safe place on the isolated network',
+ MWTip7:
+ 'Do not share and store mnemonics in a networked environment, such as emails, photo albums, social applications',
+ MWTip9: 'Do not take screenshots',
+ MWTip10: 'Do not screen capture and storage, which may be collected by third-party malware, resulting in asset loss',
+ MWTip11: 'cancel',
+ MWTip12: 'Got it',
+ MWTip13: 'Please accurately copy and safely backup the mnemonic',
+ MWTip14: 'Please click on mnemonics in order to confirm that you have backed up correctly',
+ MWTip15: 'The order of the mnemonic is incorrect,please proofread'
+}
diff --git a/src/locales/en-US/Democracy/index.js b/src/locales/en-US/Democracy/index.js
index eb06839e..2fd7d5da 100755
--- a/src/locales/en-US/Democracy/index.js
+++ b/src/locales/en-US/Democracy/index.js
@@ -1,36 +1,36 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-export default {
- // Democracy.js
- proposals: 'proposals',
- referendums: 'referendums',
- // proposals.js
- noProposals: 'no available proposals',
- depositors: 'depositors',
- balance: 'balance',
- blocksLaunch: 'blocks launch',
- // referendums.js
- Active: 'Active',
- // referendums/Active.js
- noReferendums: 'no available referendums',
- blocksEnd: 'blocks end',
- Threshold: 'Threshold',
- Aye: 'Aye',
- Nay: 'Nay',
- // secondary/NayorAye.js
- VoteSuccess: 'Vote success',
- VoteFailed: 'Vote Failed',
- Voting: 'Voting',
- vote: 'vote',
- referendumIndex: 'referendum index'
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+export default {
+ // Democracy.js
+ proposals: 'proposals',
+ referendums: 'referendums',
+ // proposals.js
+ noProposals: 'no available proposals',
+ depositors: 'depositors',
+ balance: 'balance',
+ blocksLaunch: 'blocks launch',
+ // referendums.js
+ Active: 'Active',
+ // referendums/Active.js
+ noReferendums: 'no available referendums',
+ blocksEnd: 'blocks end',
+ Threshold: 'Threshold',
+ Aye: 'Aye',
+ Nay: 'Nay',
+ // secondary/Vote.js
+ VoteSuccess: 'Vote success',
+ VoteFailed: 'Vote Failed',
+ Voting: 'Voting',
+ vote: 'vote',
+ referendumIndex: 'referendum index'
+}
diff --git a/src/locales/en-US/Profile/index.js b/src/locales/en-US/Profile/index.js
index bdc576c0..314bb487 100755
--- a/src/locales/en-US/Profile/index.js
+++ b/src/locales/en-US/Profile/index.js
@@ -1,97 +1,97 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-22 00:27:44
- */
-export default {
- Setting: 'Setting',
- ManageAccount: 'Manage Account',
- // secondary/About.js
- About: 'About',
- PolkadotApp: 'Mobile wallet for Polkadot.',
- Version: 'Version',
- // secondary/add_address.js
- addAddresses: 'Add addresses',
- Addresses: 'Addresses',
- Save: 'Save',
- SaveSuccess: 'Save Success',
-
- // secondary/address_information.js
- DeleteAddress: 'Delete Address',
- Name: 'Name',
- Memo: 'Memo',
- Address: 'Address',
-
- // secondary/Addressed.js
- // Addresses: 'Addresses',
-
- // secondary/Manage_Account.js
- deleteTip: 'Confirm deleting this account ?',
- DeleteSuccess: 'Delete success',
- ChangeName: 'Change name',
- // ChangePassword: 'Change password',
- ExportKeystore: 'Export Keystore',
- DeleteAccount: 'Delete Account',
- unlockPassword: 'Please enter your password to unlock',
- saveInformation: 'Please save your information',
- Continue: 'Continue',
- Copy: 'Copy',
-
- // secondary/Setting.js
- restartApp: 'Download finished, whether to restart the application?',
- UpdateFailed: 'Update failed.',
- toAppStore:
- 'Your application version has been updated, please go to the official website to download the new version.',
- appV: 'Your application version is up to date.',
- checkNewV: 'Check the new version:',
- download: 'whether to download?',
- nextTime: 'Next startup time',
- gestureCanceled: 'The gesture password has been canceled',
- Settings: 'Settings',
- Gesture: 'Gesture',
- RemoteNode: 'Remote Node',
- CheckUpdate: 'Check Update',
- deleteGP: 'Delete gesture password ?',
- // secondary/Change/Change_Name.js
- // CurrentPassword: 'Current password',
- NewName: 'New name',
- entPwd: 'Please enter your current password',
- entName: 'Please enter your new name',
-
- // secondary/Change/Change_Password.js
-
- CurrentPassword: 'Current password',
- NewPassword: 'New password',
- RepeatPassword: 'Repeat password',
- differentPassword: 'The two passwords are different',
- Modify: 'Modify the success',
- PasswordMistake: 'Password mistake',
- ChangePassword: 'Change Password',
- Change: 'Change',
-
- // secondary/Settings/Gesture.js
- setGesture: 'Please set the gesture password.',
- confirmGesture: 'Please confirm the gesture password.',
- gestureSuccess: 'Confirmed, password set successfully.',
- gestureFailed: 'Confirmation failed, please reset.',
- inputPWD: 'Please input your password.',
- inputPWD_d: 'Please input your password (again).',
-
- // secondary/Settings/Set_Node.js
- SetNode: 'Set Node',
- SelectNode: 'Select your Node',
- Custom: 'Custom',
- changeNode: 'Make sure you change Node to:',
- Confirm: 'Confirm',
- Cancel: 'Cancel',
- NOTETip_1: 'import remote node,if not is Alexander,not have the chart function',
- NOTETip_2: 'NOTE: Exit the app,will return to the default',
- enterNode: 'Please enter your custom Node'
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+export default {
+ Setting: 'Setting',
+ ManageAccount: 'Manage Account',
+ // secondary/About.js
+ About: 'About',
+ PolkadotApp: 'Mobile wallet for Polkadot.',
+ Version: 'Version',
+ // secondary/add_address.js
+ addAddresses: 'Add addresses',
+ Addresses: 'Addresses',
+ Save: 'Save',
+ SaveSuccess: 'Save Success',
+
+ // secondary/address_information.js
+ DeleteAddress: 'Delete Address',
+ Name: 'Name',
+ Memo: 'Memo',
+ Address: 'Address',
+
+ // secondary/Addressed.js
+ // Addresses: 'Addresses',
+
+ // secondary/Manage_Account.js
+ deleteTip: 'Confirm deleting this account ?',
+ DeleteSuccess: 'Delete success',
+ ChangeName: 'Change name',
+ // ChangePassword: 'Change password',
+ ExportKeystore: 'Export Keystore',
+ DeleteAccount: 'Delete Account',
+ unlockPassword: 'Please enter your password to unlock',
+ saveInformation: 'Please save your information',
+ Continue: 'Continue',
+ Copy: 'Copy',
+
+ // secondary/Setting.js
+ restartApp: 'Download finished, whether to restart the application?',
+ UpdateFailed: 'Update failed.',
+ toAppStore:
+ 'Your application version has been updated, please go to the official website to download the new version.',
+ appV: 'Your application version is up to date.',
+ checkNewV: 'Check the new version:',
+ download: 'whether to download?',
+ nextTime: 'Next startup time',
+ gestureCanceled: 'The gesture password has been canceled',
+ Settings: 'Settings',
+ Gesture: 'Gesture',
+ RemoteNode: 'Remote Node',
+ CheckUpdate: 'Check Update',
+ deleteGP: 'Delete gesture password ?',
+ // secondary/Change/Change_Name.js
+ // CurrentPassword: 'Current password',
+ NewName: 'New name',
+ entPwd: 'Please enter your current password',
+ entName: 'Please enter your new name',
+
+ // secondary/Change/Change_Password.js
+
+ CurrentPassword: 'Current password',
+ NewPassword: 'New password',
+ RepeatPassword: 'Repeat password',
+ differentPassword: 'The two passwords are different',
+ Modify: 'Password changed successfully',
+ PasswordMistake: 'Password mistake',
+ ChangePassword: 'Change Password',
+ Change: 'Change',
+
+ // secondary/Settings/Gesture.js
+ setGesture: 'Please set the gesture password.',
+ confirmGesture: 'Please confirm the gesture password.',
+ gestureSuccess: 'Confirmed, password set successfully.',
+ gestureFailed: 'Confirmation failed, please reset.',
+ inputPWD: 'Please input your password.',
+ inputPWD_d: 'Please input your password (again).',
+
+ // secondary/Settings/Set_Node.js
+ SetNode: 'Set Node',
+ SelectNode: 'Select your Node',
+ Custom: 'Custom',
+ changeNode: 'Make sure you change Node to:',
+ Confirm: 'Confirm',
+ Cancel: 'Cancel',
+ NOTETip_1: 'import remote node,if not is Alexander,not have the chart function',
+ NOTETip_2: 'NOTE: Exit the app,will return to the default',
+ enterNode: 'Please enter your custom Node'
+}
diff --git a/src/locales/en-US/Staking/index.js b/src/locales/en-US/Staking/index.js
index a5a6637c..e5789088 100755
--- a/src/locales/en-US/Staking/index.js
+++ b/src/locales/en-US/Staking/index.js
@@ -1,103 +1,103 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-export default {
- // Staking.js
- stakingOverview: 'Staking Overview',
- AccountActions: 'Account Actions',
- // Staking Overview 版块
- validatorsNum: 'validators',
- intentions: 'intentions',
- session: 'session',
- era: 'era',
- validators: 'Validators',
- nextUp: 'Next up',
- NoValidator: '- Not have Validator.',
- NoNextUp: 'Not have Next up',
- // Account Actions 版块
- stakingOption: 'Staking slash record, Unit(xxx)',
- stakingOption_new: 'Staking slash record, Unit',
- controller: 'controller',
- stash: 'stash',
- balance: 'balance',
- locked: 'locked',
- eraLeft: 'era left',
- BondAdditional: 'Bond Additional',
- BondFunds: 'Bond Funds',
- validate: 'validate',
- Nominate: 'Nominate',
- Unvalidate: 'Unvalidate',
- Unnominate: 'Unnominate',
- SlashRecords: 'Slash Records',
- Nominating: 'Nominating',
- MyNominators: 'MyNominators',
- noNominating: '-You are not nominating.',
- noNominee: "-You don't have nominee",
- SetSessionKey: 'SetSessionKey',
- Unbond: 'Unbond',
- PleaseChoose: 'Please choose',
- // Validator_Info.js
- Nominators: 'Nominators',
- ValidatorInfo: 'Validator Info',
- V_no_Nominator: '- Not have Nominator.',
- V_no_SR: '- Not have Slash Record.',
- // BondAdditional.js
- BondExtraFailed: 'Bond Extra Failed',
- BondExtraSuccess: 'Bond Extra success',
- BondExtra: 'Bond Extra',
- BondingPreferences: 'Bonding Preferences',
- calling: 'calling',
- additionalValue: 'max additional value',
- // BondFunds.js
- BondSuccess: 'Bond success',
- BondFailed: 'Bond Failed',
- Bonding: 'Bonding',
- Controller: 'Controller',
- payee: 'payee',
- valueBonded: 'value bonded',
- // nominate.js
- NominateSuccess: 'Nominate success',
- NominateFailed: 'Nominate Failed',
- NominateValidator: 'Nominate Validator',
- // Nominate: 'Nominate',
- multipleAddresses: 'If there are multiple addresses, separate them with a ","',
- nominateAddress: 'nominate the following address (validator or intention) ',
- // setSessionKey.js
- SessionKeyFailed: 'Set SessionKey Failed',
- SessionKeySuccess: 'Set SessionKey success',
- setSessionKey: 'Set SessionKey',
- SessionKey: 'SessionKey',
- Set: 'Set',
- // stake.js
- ValidateSuccess: 'Validate success',
- ValidateFailed: 'Validate Failed',
- Validate: 'Validate',
- unstakeThreshold: 'unstake Threshold',
- validatorPayment: 'validator Payment',
- // Unbond.js
- UnbondFailed: 'Unbond Failed',
- UnbondSuccess: 'Unbond success',
- unbondAmount: 'unbond amount',
- UnBond: 'UnBond',
- // unniminate.js
- UnnominateFailed: 'Unnominate Failed',
- UnnominateSuccess: 'Unnominate success',
- // Unnominate: 'Unnominate',
- nominateTip:
- "Will panic if called when source isn't currently nominating target. Updates Nominating, NominatorsFor and NominationBalance.",
- // unstake.js
- UnvalidateSuccess: 'Unvalidate success',
- UnvalidateFailed: 'Unvalidate Failed',
- // Unvalidate: 'Unvalidate',
- UnvalidateTip:
- 'Retract the desire to stake for the transactor. Effects will be felt at the beginning of the next era.'
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+export default {
+ // Staking.js
+ stakingOverview: 'Staking Overview',
+ AccountActions: 'Account Actions',
+ // Staking Overview 版块
+ validatorsNum: 'validators',
+ intentions: 'intentions',
+ session: 'session',
+ era: 'era',
+ validators: 'Validators',
+ nextUp: 'Next up',
+ NoValidator: '- Not have Validator.',
+ NoNextUp: 'Not have Next up',
+ // Account Actions 版块
+ stakingOption: 'Staking slash record, Unit(xxx)',
+ stakingOption_new: 'Staking slash record, Unit',
+ controller: 'controller',
+ stash: 'stash',
+ balance: 'balance',
+ locked: 'locked',
+ eraLeft: 'era left',
+ BondAdditional: 'Bond Additional',
+ BondFunds: 'Bond Funds',
+ validate: 'validate',
+ Nominate: 'Nominate',
+ Unvalidate: 'Unvalidate',
+ Unnominate: 'Unnominate',
+ SlashRecords: 'Slash Records',
+ Nominating: 'Nominating',
+ MyNominators: 'MyNominators',
+ noNominating: '-You are not nominating.',
+ noNominee: "-You don't have nominee",
+ SetSessionKey: 'SetSessionKey',
+ Unbond: 'Unbond',
+ PleaseChoose: 'Please choose',
+ // Validator_Info.js
+ Nominators: 'Nominators',
+ ValidatorInfo: 'Validator Info',
+ V_no_Nominator: '- Not have Nominator.',
+ V_no_SR: '- Not have Slash Record.',
+ // BondAdditional.js
+ BondExtraFailed: 'Bond Extra Failed',
+ BondExtraSuccess: 'Bond Extra success',
+ BondExtra: 'Bond Extra',
+ BondingPreferences: 'Bonding Preferences',
+ calling: 'calling',
+ additionalValue: 'max additional value',
+ // BondFunds.js
+ BondSuccess: 'Bond success',
+ BondFailed: 'Bond Failed',
+ Bonding: 'Bonding',
+ Controller: 'Controller',
+ payee: 'payee',
+ valueBonded: 'value bonded',
+ // nominate.js
+ NominateSuccess: 'Nominate success',
+ NominateFailed: 'Nominate Failed',
+ NominateValidator: 'Nominate Validator',
+ // Nominate: 'Nominate',
+ multipleAddresses: 'If there are multiple addresses, separate them with a ","',
+ nominateAddress: 'nominate the following address (validator or intention) ',
+ // setSessionKey.js
+ SessionKeyFailed: 'Set SessionKey Failed',
+ SessionKeySuccess: 'Set SessionKey success',
+ setSessionKey: 'Set SessionKey',
+ SessionKey: 'SessionKey',
+ Set: 'Set',
+ // stake.js
+ ValidateSuccess: 'Validate success',
+ ValidateFailed: 'Validate Failed',
+ Validate: 'Validate',
+ unstakeThreshold: 'unstake Threshold',
+ validatorPayment: 'validator Payment',
+ // Unbond.js
+ UnbondFailed: 'Unbond Failed',
+ UnbondSuccess: 'Unbond success',
+ unbondAmount: 'unbond amount',
+ UnBond: 'UnBond',
+ // unniminate.js
+ UnnominateFailed: 'Unnominate Failed',
+ UnnominateSuccess: 'Unnominate success',
+ // Unnominate: 'Unnominate',
+ nominateTip:
+ "Will panic if called when source isn't currently nominating target. Updates Nominating, NominatorsFor and NominationBalance.",
+ // unstake.js
+ UnvalidateSuccess: 'Unvalidate success',
+ UnvalidateFailed: 'Unvalidate Failed',
+ // Unvalidate: 'Unvalidate',
+ UnvalidateTip:
+ 'Retract the desire to stake for the transactor. Effects will be felt at the beginning of the next era.'
+}
diff --git a/src/locales/en-US/index.js b/src/locales/en-US/index.js
index 818a08c9..67aba4b6 100755
--- a/src/locales/en-US/index.js
+++ b/src/locales/en-US/index.js
@@ -1,58 +1,58 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import Assets from './Assets/index'
-import Staking from './Staking/index'
-import Democracy from './Democracy/index'
-import Profile from './Profile/index'
-
-export default {
- TAB: {
- Assets: 'Assets',
- Staking: 'Staking',
- Democracy: 'Democracy',
- Profile: 'Profile',
- ChangeLanguages: 'Change Languages',
- PasswordMistake: 'Password mistake.',
- PasswordCorrect: 'Password is correct.',
- Reset: 'Reset',
- Save: 'Save',
- Exit: 'Exit',
- Copy: 'Copy',
- Continue: 'Continue',
- Cancel: 'Cancel',
- StakingOption: 'Assets change record, Unit(xxx) ',
- Receive: 'Receive',
- Received: 'Received',
- Send: 'Send',
- loadMore: 'To load more ~',
- Bottom: '~ Bottom',
- noResponse: 'Long time no response, please try again.',
- enterInformation: 'Please enter relevant information.',
- signMess: 'You are about to sign a message from',
- unlockPassword: 'unlock account using password',
- loading: 'loading',
- CopySuccess: 'Copy success'
- },
- Assets: {
- ...Assets
- },
- Staking: {
- ...Staking
- },
- Democracy: {
- ...Democracy
- },
- Profile: {
- ...Profile
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import Assets from './Assets/index'
+import Staking from './Staking/index'
+import Democracy from './Democracy/index'
+import Profile from './Profile/index'
+
+export default {
+ TAB: {
+ Assets: 'Assets',
+ Staking: 'Staking',
+ Democracy: 'Democracy',
+ Profile: 'Profile',
+ ChangeLanguages: 'Change Languages',
+ PasswordMistake: 'Password mistake.',
+ PasswordCorrect: 'Password is correct.',
+ Reset: 'Reset',
+ Save: 'Save',
+ Exit: 'Exit',
+ Copy: 'Copy',
+ Continue: 'Continue',
+ Cancel: 'Cancel',
+ StakingOption: 'Assets change record, Unit(xxx) ',
+ Receive: 'Receive',
+ Received: 'Received',
+ Send: 'Send',
+ loadMore: 'To load more ~',
+ Bottom: '~ Bottom',
+ noResponse: 'Long time no response, please try again.',
+ enterInformation: 'Please enter relevant information.',
+ signMess: 'You are about to sign a message from',
+ unlockPassword: 'unlock account using password',
+ loading: 'loading',
+ CopySuccess: 'Copy success'
+ },
+ Assets: {
+ ...Assets
+ },
+ Staking: {
+ ...Staking
+ },
+ Democracy: {
+ ...Democracy
+ },
+ Profile: {
+ ...Profile
+ }
+}
diff --git a/src/locales/i18n.js b/src/locales/i18n.js
index b8149f59..487b79d6 100755
--- a/src/locales/i18n.js
+++ b/src/locales/i18n.js
@@ -1,37 +1,37 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import i18n from 'react-native-i18n'
-import en from './en-US/index'
-import zh from './zh-CN/index'
-import DataRepository from '../util/DataRepository'
-
-i18n.defaultLocale = 'en'
-i18n.fallbacks = true
-i18n.translations = {
- zh,
- en
-}
-i18n.localeLanguage = () => {
- new DataRepository()
- .fetchLocalRepository('localLanguage')
- .then(res => {
- i18n.locale = res
- })
- .catch(() => {
- i18n.locale = 'en'
- })
-
- return i18n.locale
-}
-i18n.locale = 'en'
-export default i18n
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import i18n from 'react-native-i18n'
+import en from './en-US/index'
+import zh from './zh-CN/index'
+import DataRepository from '../util/DataRepository'
+
+i18n.defaultLocale = 'en'
+i18n.fallbacks = true
+i18n.translations = {
+ zh,
+ en
+}
+i18n.localeLanguage = () => {
+ new DataRepository()
+ .fetchLocalRepository('localLanguage')
+ .then(res => {
+ i18n.locale = res
+ })
+ .catch(() => {
+ i18n.locale = 'en'
+ })
+
+ return i18n.locale
+}
+i18n.locale = 'en'
+export default i18n
diff --git a/src/locales/zh-CN/Assets/index.js b/src/locales/zh-CN/Assets/index.js
index 382863ab..1939526a 100755
--- a/src/locales/zh-CN/Assets/index.js
+++ b/src/locales/zh-CN/Assets/index.js
@@ -1,96 +1,96 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-21 20:09:00
- */
-export default {
- Alexander: 'Alexander 测试网',
- Receive: '接收',
- Account: '账户',
- AssetsList: '资产列表',
- Menu: '菜单',
- Scan: '扫描',
- CreateAccount: '创建账户',
- // Create_Account 页面
- balance: '余额',
- Createfrom: '用助记词、种子创建,或导入keystore',
- WordMnemonic12: '12词助记词',
- WordMnemonic24: '24词助记词',
- RawSeed: '密钥种子',
- ImportKeystore: '导入keystore',
- NameTheAccount: '账户名字',
- Password: '密码',
- EnterName: '请输入名称',
- EnterPassword: '请输入密码',
- EnterPassword_d: '请确认密码',
- CheckPassword: '两次密码不一致,请再次输入',
- ExistingAddress: '该地址已存在!',
- // Backup_Account 页面
- Warning: '注意',
- BeforeSafe: '请确保已经备份了信息在安全的地方。',
- Restore: '用于以后恢复账户',
- // camera 页面
- QRCodeTip: '将二维码放入框中,即可自动扫描',
- Flashlight: '照明开关',
- // coin_details 页面
- AssetsOption: '资产变化记录,单位(xxx)',
- AssetsOption_new: '资产变化记录,单位',
- // make_transfer 页面
-
- Transfer: 'DOT 交易',
- TransferFailed: '交易失败',
- TransferSuccess: '交易成功',
- SubmitTransaction: '发起交易',
- recipientAddress: '接收地址',
- sendOf: '发送数量',
- send: '发送',
- PleaseEnterAddress: '请输入地址',
- creationFee: '创建账户手续费',
- existentialDeposit: '账户存在最低存额',
- transactionBaseFee: '交易基础手续费',
- transactionByteFee: '交易字节费',
- transferFee: '转账费',
- MakeTransfer: '发送交易',
-
- // Transfer 页面
- enterValue: '请输入发送数量',
- enterInformation: '请输入正确的信息',
- // Transfer_details 页面
- Details: '交易详情',
- Successed: '成功',
- Balance: '金额',
- Fees: '手续费',
- To: '接收方',
- From: '发送方',
- Block: '区块高度',
- BlockHash: '区块哈希',
- // make_transfer 页面
- calling: '调用',
- withIndex: '账户交易编号',
- SignAndSubmit: '签名并提交',
- // Receive
- CopyAddress: '复制地址',
- // MnemonicWord.js
- MWTitle: '备份提示',
- MWTip1: '获得助记词等于拥有钱包资产所有权',
- MWTip2: '备份助记词',
- MWTip3: '使用纸和笔正确抄写助记词',
- MWTip4: '如果你的手机丢失、被盗、损坏,助记词将可以恢复你的资产',
- MWTip5: '离线保存',
- MWTip6: '妥善保管至隔离网络的安全地方',
- MWTip7: '请勿将助记词在联网环境下分享和储存,比如邮件、相册、社交应用等',
- MWTip9: '请勿截屏',
- MWTip10: '请勿截屏分享和存储,这将可能被第三方恶意软件手机,造成资产损坏',
- MWTip11: '取消',
- MWTip12: '知道了',
- MWTip13: '请准确抄写并安全备份助记词。',
- MWTip14: '请按顺序点击助记词,以确认您正确备份。',
- MWTip15: '助记词顺序不正确,请校对'
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+export default {
+ Alexander: 'Alexander 测试网',
+ Receive: '接收',
+ Account: '账户',
+ AssetsList: '资产列表',
+ Menu: '菜单',
+ Scan: '扫描',
+ CreateAccount: '创建账户',
+ // Create_Account 页面
+ balance: '余额',
+ Createfrom: '用助记词、种子创建,或导入keystore',
+ WordMnemonic12: '12词助记词',
+ WordMnemonic24: '24词助记词',
+ RawSeed: '密钥种子',
+ ImportKeystore: '导入keystore',
+ NameTheAccount: '账户名字',
+ Password: '密码',
+ EnterName: '请输入名称',
+ EnterPassword: '请输入密码',
+ EnterPassword_d: '请确认密码',
+ CheckPassword: '两次密码不一致,请再次输入',
+ ExistingAddress: '该地址已存在!',
+ // Backup_Account 页面
+ Warning: '注意',
+ BeforeSafe: '请确保已经备份了信息在安全的地方。',
+ Restore: '用于以后恢复账户',
+ // camera 页面
+ QRCodeTip: '将二维码放入框中,即可自动扫描',
+ Flashlight: '照明开关',
+ // coin_details 页面
+ AssetsOption: '资产变化记录,单位(xxx)',
+ AssetsOption_new: '资产变化记录,单位',
+ // make_transfer 页面
+
+ Transfer: 'DOT 交易',
+ TransferFailed: '交易失败',
+ TransferSuccess: '交易成功',
+ SubmitTransaction: '发起交易',
+ recipientAddress: '接收地址',
+ sendOf: '发送数量',
+ send: '发送',
+ PleaseEnterAddress: '请输入地址',
+ creationFee: '创建账户手续费',
+ existentialDeposit: '账户存在最低存额',
+ transactionBaseFee: '交易基础手续费',
+ transactionByteFee: '交易字节费',
+ transferFee: '转账费',
+ MakeTransfer: '发送交易',
+
+ // Transfer 页面
+ enterValue: '请输入发送数量',
+ enterInformation: '请输入正确的信息',
+ // Transfer_details 页面
+ Details: '交易详情',
+ Successed: '成功',
+ Balance: '金额',
+ Fees: '手续费',
+ To: '接收方',
+ From: '发送方',
+ Block: '区块高度',
+ BlockHash: '区块哈希',
+ // make_transfer 页面
+ calling: '调用',
+ withIndex: '账户交易编号',
+ SignAndSubmit: '签名并提交',
+ // Receive
+ CopyAddress: '复制地址',
+ // MnemonicWord.js
+ MWTitle: '备份提示',
+ MWTip1: '获得助记词等于拥有钱包资产所有权',
+ MWTip2: '备份助记词',
+ MWTip3: '使用纸和笔正确抄写助记词',
+ MWTip4: '如果你的手机丢失、被盗、损坏,助记词将可以恢复你的资产',
+ MWTip5: '离线保存',
+ MWTip6: '妥善保管至隔离网络的安全地方',
+ MWTip7: '请勿将助记词在联网环境下分享和储存,比如邮件、相册、社交应用等',
+ MWTip9: '请勿截屏',
+ MWTip10: '请勿截屏分享和存储,这将可能被第三方恶意软件手机,造成资产损坏',
+ MWTip11: '取消',
+ MWTip12: '知道了',
+ MWTip13: '请准确抄写并安全备份助记词。',
+ MWTip14: '请按顺序点击助记词,以确认您正确备份。',
+ MWTip15: '助记词顺序不正确,请校对'
+}
diff --git a/src/locales/zh-CN/Democracy/index.js b/src/locales/zh-CN/Democracy/index.js
index 523478dd..770768cd 100755
--- a/src/locales/zh-CN/Democracy/index.js
+++ b/src/locales/zh-CN/Democracy/index.js
@@ -1,36 +1,36 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-export default {
- // Democracy.js
- proposals: '提案',
- referendums: '公投',
- // proposals.js
- noProposals: '没有可用的提案',
- depositors: '寄托人',
- balance: '金额',
- blocksLaunch: '区块后发起',
- // referendums.js
- Active: '正在进行',
- // referendums/Active.js
- noReferendums: '没有正在进行的公投',
- blocksEnd: '区块后结束',
- Threshold: '阀值',
- Aye: '赞成',
- Nay: '反对',
- // secondary/NayorAye.js
- VoteSuccess: '投票成功!',
- VoteFailed: '投票失败!',
- Voting: '投票',
- vote: '投票',
- referendumIndex: '公投编号'
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+export default {
+ // Democracy.js
+ proposals: '提案',
+ referendums: '公投',
+ // proposals.js
+ noProposals: '没有可用的提案',
+ depositors: '寄托人',
+ balance: '金额',
+ blocksLaunch: '区块后发起',
+ // referendums.js
+ Active: '正在进行',
+ // referendums/Active.js
+ noReferendums: '没有正在进行的公投',
+ blocksEnd: '区块后结束',
+ Threshold: '阀值',
+ Aye: '赞成',
+ Nay: '反对',
+ // secondary/NayorAye.js
+ VoteSuccess: '投票成功!',
+ VoteFailed: '投票失败!',
+ Voting: '投票',
+ vote: '投票',
+ referendumIndex: '公投编号'
+}
diff --git a/src/locales/zh-CN/Profile/index.js b/src/locales/zh-CN/Profile/index.js
index d0c03a0a..81e0d17b 100755
--- a/src/locales/zh-CN/Profile/index.js
+++ b/src/locales/zh-CN/Profile/index.js
@@ -1,95 +1,95 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-22 00:28:12
- */
-export default {
- ManageAccount: '账户管理',
- Setting: '设置',
- // secondary/About.js
- About: '关于',
- PolkadotApp: 'Polkadot生态移动端钱包。',
- Version: '版本',
- // secondary/add_address.js
- Addresses: '地址薄',
- Save: '保存',
- SaveSuccess: '保存成功',
-
- // secondary/address_information.js
-
- addAddresses: '添加地址',
- DeleteAddress: '删除地址',
- Name: '名称',
- Memo: '备注',
- Address: '地址',
-
- // secondary/Addressed.js
-
- // secondary/Manage_Account.js
- deleteTip: '确认删除此账户?',
- DeleteSuccess: '账户删除成功!',
- ChangeName: '修改名称',
- ChangePassword: '修改密码',
- ExportKeystore: '导出 Keystore',
- DeleteAccount: '删除账户',
- unlockPassword: '请输入密码解锁账户',
- saveInformation: '请保存你的信息',
- Continue: '继续',
- Copy: '复制',
-
- // secondary/Setting.js
- restartApp: '下载完成,是否重启应用?',
- UpdateFailed: '更新失败',
- toAppStore: '应用版本有更新,请去官网下载新版本',
- appV: '已经是最新版本',
- checkNewV: '检查到新版本',
- download: '是否下载?',
- nextTime: '下次再说',
- gestureCanceled: '手势密码修改成功',
- Settings: '配置',
- Gesture: '手势',
- RemoteNode: '远程节点',
- CheckUpdate: '检查更新',
- deleteGP: '删除手势密码?',
- // secondary/Change/Change_Name.js
- CurrentPassword: '输入密码',
- NewName: '新名称',
- entPwd: '请输入当前密码',
- entName: '请输入新名称',
- // secondary/Change/Change_Password.js
-
- // CurrentPassword: '当前密码',
- NewPassword: '新密码',
- RepeatPassword: '确认密码',
- differentPassword: '两次密码输入不一致',
- Modify: '修改成功!',
- PasswordMistake: '密码错误',
- // ChangePassword: '修改密码',
- Change: '修改',
-
- // secondary/Settings/Gesture.js
- setGesture: '请设置手势密码',
- confirmGesture: '请确认手势密码',
- gestureSuccess: '手势密码设置成功!',
- gestureFailed: '手势密码设置失败,请重新设置',
- inputPWD: '请输入手势密码',
- inputPWD_d: '请再次输入手势密码',
-
- // secondary/Settings/Set_Node.js
- SetNode: '设置节点',
- SelectNode: '选择连接节点',
- Custom: '自定义',
- changeNode: '确认节点连接:',
- Confirm: '确认',
- Cancel: '取消',
- NOTETip_1: '导入节点连接,如果不是Alexander,则没有图表功能。',
- NOTETip_2: '注:退出app,将返回默认节点',
- enterNode: '请输入自定义节点'
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+export default {
+ ManageAccount: '账户管理',
+ Setting: '设置',
+ // secondary/About.js
+ About: '关于',
+ PolkadotApp: 'Polkadot生态移动端钱包。',
+ Version: '版本',
+ // secondary/add_address.js
+ Addresses: '地址薄',
+ Save: '保存',
+ SaveSuccess: '保存成功',
+
+ // secondary/address_information.js
+
+ addAddresses: '添加地址',
+ DeleteAddress: '删除地址',
+ Name: '名称',
+ Memo: '备注',
+ Address: '地址',
+
+ // secondary/Addressed.js
+
+ // secondary/Manage_Account.js
+ deleteTip: '确认删除此账户?',
+ DeleteSuccess: '账户删除成功!',
+ ChangeName: '修改名称',
+ ChangePassword: '修改密码',
+ ExportKeystore: '导出 Keystore',
+ DeleteAccount: '删除账户',
+ unlockPassword: '请输入密码解锁账户',
+ saveInformation: '请保存你的信息',
+ Continue: '继续',
+ Copy: '复制',
+
+ // secondary/Setting.js
+ restartApp: '下载完成,是否重启应用?',
+ UpdateFailed: '更新失败',
+ toAppStore: '应用版本有更新,请去官网下载新版本',
+ appV: '已经是最新版本',
+ checkNewV: '检查到新版本',
+ download: '是否下载?',
+ nextTime: '下次再说',
+ gestureCanceled: '手势密码修改成功',
+ Settings: '配置',
+ Gesture: '手势',
+ RemoteNode: '远程节点',
+ CheckUpdate: '检查更新',
+ deleteGP: '删除手势密码?',
+ // secondary/Change/Change_Name.js
+ CurrentPassword: '输入密码',
+ NewName: '新名称',
+ entPwd: '请输入当前密码',
+ entName: '请输入新名称',
+ // secondary/Change/Change_Password.js
+
+ // CurrentPassword: '当前密码',
+ NewPassword: '新密码',
+ RepeatPassword: '确认密码',
+ differentPassword: '两次密码输入不一致',
+ Modify: '修改成功!',
+ PasswordMistake: '密码错误',
+ // ChangePassword: '修改密码',
+ Change: '修改',
+
+ // secondary/Settings/Gesture.js
+ setGesture: '请设置手势密码',
+ confirmGesture: '请确认手势密码',
+ gestureSuccess: '手势密码设置成功!',
+ gestureFailed: '手势密码设置失败,请重新设置',
+ inputPWD: '请输入手势密码',
+ inputPWD_d: '请再次输入手势密码',
+
+ // secondary/Settings/Set_Node.js
+ SetNode: '设置节点',
+ SelectNode: '选择连接节点',
+ Custom: '自定义',
+ changeNode: '确认节点连接:',
+ Confirm: '确认',
+ Cancel: '取消',
+ NOTETip_1: '导入节点连接,如果不是Alexander,则没有图表功能。',
+ NOTETip_2: '注:退出app,将返回默认节点',
+ enterNode: '请输入自定义节点'
+}
diff --git a/src/locales/zh-CN/Staking/index.js b/src/locales/zh-CN/Staking/index.js
index dccb0b60..e46c0f6b 100755
--- a/src/locales/zh-CN/Staking/index.js
+++ b/src/locales/zh-CN/Staking/index.js
@@ -1,100 +1,100 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-export default {
- // Staking.js
- stakingOverview: '抵押概况',
- AccountActions: '账户操作',
- // Staking Overview 版块
- validatorsNum: '验证者数量',
- intentions: '意图者数量',
- session: '会话周期',
- era: '时代周期',
- validators: '验证者',
- nextUp: '候选人',
- NoValidator: '没有验证者,或网络延时',
- NoNextUp: '没有候选人,或网络延时',
- // Account Actions 版块
- stakingOption: '削减历史记录,单位(xxx)',
- stakingOption_new: '削减历史记录,单位',
- controller: '控制账户',
- stash: '存储账户',
- balance: '余额',
- locked: '锁定',
- eraLeft: '剩下时代数',
- BondAdditional: '追加绑定',
- BondFunds: '绑定',
- validate: '验证',
- Nominate: '提名',
- Unvalidate: '取消验证',
- Unnominate: '取消提名',
- SlashRecords: '削减记录',
- Nominating: '我正在提名',
- MyNominators: '提名我的',
- noNominating: '没有正在提名',
- noNominee: '没有提名者',
- SetSessionKey: '设置会话账户',
- Unbond: '解绑',
- PleaseChoose: '请选择',
- // Validator_Info.js
- Nominators: '提名者',
- ValidatorInfo: '验证者详情',
- V_no_Nominator: '没有提名人',
- V_no_SR: '没有削减记录',
- // BondAdditional.js
- BondExtraFailed: '追加绑定失败!',
- BondExtraSuccess: '追加绑定成功!',
- BondExtra: '追加绑定',
- BondingPreferences: '绑定参数',
- calling: '调用',
- additionalValue: '追加金额',
- // BondFunds.js
- BondSuccess: '绑定成功!',
- BondFailed: '绑定失败!',
- Bonding: '绑定',
- Controller: '控制账户',
- payee: '受益人',
- valueBonded: '绑定金额',
- // nominate.js
- NominateSuccess: '提名成功!',
- NominateFailed: '提名失败!',
- NominateValidator: '提名验证者',
- nominateAddress: '提名地址(验证者或意图者)',
- multipleAddresses: '如果有多个地址,请用","隔开',
- // setSessionKey.js
- SessionKeyFailed: '设置会话账户失败!',
- SessionKeySuccess: '设置会话账户成功!',
- setSessionKey: '设置会话账户',
- SessionKey: '会话账户',
- Set: '设置',
- // stake.js
- ValidateSuccess: '发起验证成功!',
- ValidateFailed: '发起验证失败!',
- Validate: '验证',
- unstakeThreshold: '自动取消阀值',
- validatorPayment: '保留奖励',
- // Unbond.js
- UnbondFailed: '解绑失败!',
- UnbondSuccess: '解绑成功!',
- unbondAmount: '解绑总额',
- UnBond: '解绑',
- // unniminate.js
- UnnominateFailed: '取消提名失败!',
- UnnominateSuccess: '取消提名成功!',
- // Unnominate: '取消提名',
- nominateTip: '如果没有正在提名却调用该方法会引起错误。',
- // unstake.js
- UnvalidateSuccess: '取消验证成功!',
- UnvalidateFailed: '取消验证失败!',
- // Unvalidate: '取消验证',
- UnvalidateTip: '撤回验证意愿,将在下一个时代生效。'
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+export default {
+ // Staking.js
+ stakingOverview: '抵押概况',
+ AccountActions: '账户操作',
+ // Staking Overview 版块
+ validatorsNum: '验证者数量',
+ intentions: '意图者数量',
+ session: '会话周期',
+ era: '时代周期',
+ validators: '验证者',
+ nextUp: '候选人',
+ NoValidator: '没有验证者,或网络延时',
+ NoNextUp: '没有候选人,或网络延时',
+ // Account Actions 版块
+ stakingOption: '削减历史记录,单位(xxx)',
+ stakingOption_new: '削减历史记录,单位',
+ controller: '控制账户',
+ stash: '存储账户',
+ balance: '余额',
+ locked: '锁定',
+ eraLeft: '剩下时代数',
+ BondAdditional: '追加绑定',
+ BondFunds: '绑定',
+ validate: '验证',
+ Nominate: '提名',
+ Unvalidate: '取消验证',
+ Unnominate: '取消提名',
+ SlashRecords: '削减记录',
+ Nominating: '我正在提名',
+ MyNominators: '提名我的',
+ noNominating: '没有正在提名',
+ noNominee: '没有提名者',
+ SetSessionKey: '设置会话账户',
+ Unbond: '解绑',
+ PleaseChoose: '请选择',
+ // Validator_Info.js
+ Nominators: '提名者',
+ ValidatorInfo: '验证者详情',
+ V_no_Nominator: '没有提名人',
+ V_no_SR: '没有削减记录',
+ // BondAdditional.js
+ BondExtraFailed: '追加绑定失败!',
+ BondExtraSuccess: '追加绑定成功!',
+ BondExtra: '追加绑定',
+ BondingPreferences: '绑定参数',
+ calling: '调用',
+ additionalValue: '追加金额',
+ // BondFunds.js
+ BondSuccess: '绑定成功!',
+ BondFailed: '绑定失败!',
+ Bonding: '绑定',
+ Controller: '控制账户',
+ payee: '受益人',
+ valueBonded: '绑定金额',
+ // nominate.js
+ NominateSuccess: '提名成功!',
+ NominateFailed: '提名失败!',
+ NominateValidator: '提名验证者',
+ nominateAddress: '提名地址(验证者或意图者)',
+ multipleAddresses: '如果有多个地址,请用","隔开',
+ // setSessionKey.js
+ SessionKeyFailed: '设置会话账户失败!',
+ SessionKeySuccess: '设置会话账户成功!',
+ setSessionKey: '设置会话账户',
+ SessionKey: '会话账户',
+ Set: '设置',
+ // stake.js
+ ValidateSuccess: '发起验证成功!',
+ ValidateFailed: '发起验证失败!',
+ Validate: '验证',
+ unstakeThreshold: '自动取消阀值',
+ validatorPayment: '保留奖励',
+ // Unbond.js
+ UnbondFailed: '解绑失败!',
+ UnbondSuccess: '解绑成功!',
+ unbondAmount: '解绑总额',
+ UnBond: '解绑',
+ // unniminate.js
+ UnnominateFailed: '取消提名失败!',
+ UnnominateSuccess: '取消提名成功!',
+ // Unnominate: '取消提名',
+ nominateTip: '如果没有正在提名却调用该方法会引起错误。',
+ // unstake.js
+ UnvalidateSuccess: '取消验证成功!',
+ UnvalidateFailed: '取消验证失败!',
+ // Unvalidate: '取消验证',
+ UnvalidateTip: '撤回验证意愿,将在下一个时代生效。'
+}
diff --git a/src/locales/zh-CN/index.js b/src/locales/zh-CN/index.js
index 08ba7b6e..694d12db 100755
--- a/src/locales/zh-CN/index.js
+++ b/src/locales/zh-CN/index.js
@@ -1,57 +1,57 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import Assets from './Assets/index'
-import Staking from './Staking/index'
-import Democracy from './Democracy/index'
-import Profile from './Profile/index'
-
-export default {
- TAB: {
- Assets: '资产',
- Staking: '抵押',
- Democracy: '民主',
- Profile: '设置',
- ChangeLanguages: '更换语言',
- PasswordMistake: '密码错误',
- PasswordCorrect: '密码正确',
- Reset: '重置',
- Save: '保存',
- Continue: '继续',
- Cancel: '取消',
- StakingOption: '资产变化记录,单位(xxx) ',
- Receive: '接收',
- Received: '接收',
- Send: '发送',
- loadMore: '加载更多',
- Bottom: '到底啦',
- noResponse: '反应超时,请再次尝试。',
- enterInformation: '请输入相关信息',
- signMess: '正在用该账户进行签名',
- unlockPassword: '输入密码解锁账户',
- loading: '加载中',
- CopySuccess: '复制成功',
- Copy: '复制'
- },
- Assets: {
- ...Assets
- },
- Staking: {
- ...Staking
- },
- Democracy: {
- ...Democracy
- },
- Profile: {
- ...Profile
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import Assets from './Assets/index'
+import Staking from './Staking/index'
+import Democracy from './Democracy/index'
+import Profile from './Profile/index'
+
+export default {
+ TAB: {
+ Assets: '资产',
+ Staking: '抵押',
+ Democracy: '民主',
+ Profile: '设置',
+ ChangeLanguages: '更换语言',
+ PasswordMistake: '密码错误',
+ PasswordCorrect: '密码正确',
+ Reset: '重置',
+ Save: '保存',
+ Continue: '继续',
+ Cancel: '取消',
+ StakingOption: '资产变化记录,单位(xxx) ',
+ Receive: '接收',
+ Received: '接收',
+ Send: '发送',
+ loadMore: '加载更多',
+ Bottom: '到底啦',
+ noResponse: '反应超时,请再次尝试。',
+ enterInformation: '请输入相关信息',
+ signMess: '正在用该账户进行签名',
+ unlockPassword: '输入密码解锁账户',
+ loading: '加载中',
+ CopySuccess: '复制成功',
+ Copy: '复制'
+ },
+ Assets: {
+ ...Assets
+ },
+ Staking: {
+ ...Staking
+ },
+ Democracy: {
+ ...Democracy
+ },
+ Profile: {
+ ...Profile
+ }
+}
diff --git a/src/mobx/mobx.js b/src/mobx/mobx.js
index 64fd50ce..ef486b15 100755
--- a/src/mobx/mobx.js
+++ b/src/mobx/mobx.js
@@ -1,136 +1,137 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-21 22:42:42
- */
-import { observable } from 'mobx'
-
-class StateStore {
- // 被观察的字段
- // Observed field
- @observable name = 'Zoey'
-
- // 被观察的字段
- // Observed field
- @observable API = {}
-
- // wss
- // @observable ENDPOINT = 'wss://poc3-rpc.polkadot.io/'
- @observable ENDPOINT = 'ws://45.32.115.98:9944/'
-
- // 是否是第一次登陆
- // first time to use
- @observable isfirst = 0
-
- // 所有账户
- // All accounts
- @observable Accounts = [{ account: 'NeedCreate', address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' }]
-
- // 通讯录
- // Addresses
- @observable Addresses = []
-
- // 正在登陆的账户
- // Using account
- @observable Account = 0
-
- // 账户数量(除默认账户以外)
- // Account number (except default account)
- @observable Accountnum = 0
-
- // 刷新前登陆的账户
- // Refresh previously used accounts
- @observable refreshBefore = 0
-
- // 交易信息
- // Transaction infomation
- @observable transactions = {}
-
- // 当前交易信息是否是最后一页
- // Whether the current transaction information is the last page
- @observable hasNextPage
-
- // 当前账户在balances中的位置
- // Index of current account's balance in the balances
- @observable balanceIndex = 0
-
- // 所有账户balance
- // All accounts balance
- @observable balances = [{ address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx', balance: 0 }]
-
- // 所有账户中有没有这个用户地址
- // Address duplicate exists
- @observable have = 0
-
- // balance
- @observable balance = '0'
-
- // 转账地址
- // Transfer address
- @observable inaddress = ''
-
- // 转账金额
- // Transfer value
- @observable value = 0
-
- // 第几笔交易
- // Transfer nonce
- @observable accountNonce = 0
-
- //* ****************** */Democracy界面*******************
- // referendumCount
- @observable referendumCount = '0'
-
- // 转到通讯录
- // Go to the address book
- @observable transfer_address = 0
-
- // 选中地址
- // Selected address
- @observable t_address = ''
-
- // 是否是从通讯录中选出的地址
- // Is selected from the address book?
- @observable isaddresses = 0
-
- // 判断是从哪里进入的nominate
- // 0代表从Account Actions界面,1代表Staking Overview
- // Determine which page to nominate; 0: from Account Actions; 1: from Staking Overview;
- @observable tonominate = 0
-
- // 判断是从哪里扫过来的
- // 0代表从Assets界面,1代表transfer,2代表通讯录
- // Determine where it Scan Qr from; 0: from Assets page; 1: from Addresses page;
- @observable tocamera = 0
-
- // 是否是扫码得到的地址
- // Got address from scan Qr?
- @observable iscamera = 0
-
- // 二维码扫描到的地址
- // The address from scan Qr
- @observable QRaddress = ''
-
- //* **************************** 设置 ***********************************
- // 手势密码
- // Gestures password
- @observable Gesture = ''
-
- // 手势密码的模式:0 代表无密码,1 代表确认密码,2 代表验证密码
- // The pattern of the gesture password; 0: no password, 1:confirm password, 2: verify password
- @observable GestureState = 0
-}
-
-class RootStore {
- constructor() {
- this.stateStore = new StateStore()
- }
-}
-export default new RootStore()
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import { observable } from 'mobx'
+
+class StateStore {
+ // 被观察的字段
+ // Observed field
+ @observable name = 'Zoey'
+
+ // 被观察的字段
+ // Observed field
+ @observable API = {}
+
+ // wss
+ // @observable ENDPOINT = 'wss://poc3-rpc.polkadot.io/'
+ // @observable ENDPOINT = 'ws://45.32.115.98:9944/'
+ @observable ENDPOINT = 'ws://140.82.35.183:9944/'
+
+ // 是否是第一次登陆
+ // first time to use
+ @observable isfirst = 0
+
+ // 所有账户
+ // All accounts
+ @observable Accounts = [{ account: 'NeedCreate', address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' }]
+
+ // 通讯录
+ // Addresses
+ @observable Addresses = []
+
+ // 正在登陆的账户
+ // Using account
+ @observable Account = 0
+
+ // 账户数量(除默认账户以外)
+ // Account number (except default account)
+ @observable Accountnum = 0
+
+ // 刷新前登陆的账户
+ // Refresh previously used accounts
+ @observable refreshBefore = 0
+
+ // 交易信息
+ // Transaction infomation
+ @observable transactions = {}
+
+ // 当前交易信息是否是最后一页
+ // Whether the current transaction information is the last page
+ @observable hasNextPage
+
+ // 当前账户在balances中的位置
+ // Index of current account's balance in the balances
+ @observable balanceIndex = 0
+
+ // 所有账户balance
+ // All accounts balance
+ @observable balances = [{ address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx', balance: 0 }]
+
+ // 所有账户中有没有这个用户地址
+ // Address duplicate exists
+ @observable have = 0
+
+ // balance
+ @observable balance = '0'
+
+ // 转账地址
+ // Transfer address
+ @observable inaddress = ''
+
+ // 转账金额
+ // Transfer value
+ @observable value = 0
+
+ // 第几笔交易
+ // Transfer nonce
+ @observable accountNonce = 0
+
+ //* ****************** */Democracy界面*******************
+ // referendumCount
+ @observable referendumCount = '0'
+
+ // 转到通讯录
+ // Go to the address book
+ @observable transfer_address = 0
+
+ // 选中地址
+ // Selected address
+ @observable t_address = ''
+
+ // 是否是从通讯录中选出的地址
+ // Is selected from the address book?
+ @observable isaddresses = 0
+
+ // 判断是从哪里进入的nominate
+ // 0代表从Account Actions界面,1代表Staking Overview
+ // Determine which page to nominate; 0: from Account Actions; 1: from Staking Overview;
+ @observable tonominate = 0
+
+ // 判断是从哪里扫过来的
+ // 0代表从Assets界面,1代表transfer,2代表通讯录
+ // Determine where it Scan Qr from; 0: from Assets page; 1: from Addresses page;
+ @observable tocamera = 0
+
+ // 是否是扫码得到的地址
+ // Got address from scan Qr?
+ @observable iscamera = 0
+
+ // 二维码扫描到的地址
+ // The address from scan Qr
+ @observable QRaddress = ''
+
+ //* **************************** 设置 ***********************************
+ // 手势密码
+ // Gestures password
+ @observable Gesture = ''
+
+ // 手势密码的模式:0 代表无密码,1 代表确认密码,2 代表验证密码
+ // The pattern of the gesture password; 0: no password, 1:confirm password, 2: verify password
+ @observable GestureState = 0
+}
+
+class RootStore {
+ constructor() {
+ this.stateStore = new StateStore()
+ }
+}
+export default new RootStore()
diff --git a/src/page/Assets/Assets.js b/src/page/Assets/Assets.js
index 63eeab62..1c5893c3 100755
--- a/src/page/Assets/Assets.js
+++ b/src/page/Assets/Assets.js
@@ -1,746 +1,796 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-21 21:14:28
- */
-import React, { Component } from 'react'
-import {
- Text,
- View,
- Image,
- TouchableOpacity,
- SafeAreaView,
- StatusBar,
- AsyncStorage,
- AppState,
- Alert,
- Animated,
- Platform,
- ImageBackground,
- StyleSheet,
- Modal
-} from 'react-native'
-import {
- isFirstTime,
- checkUpdate,
- downloadUpdate,
- switchVersion,
- switchVersionLater,
- markSuccess
-} from 'react-native-update'
-import Api from '@polkadot/api/promise'
-import WsProvider from '@polkadot/rpc-provider/ws'
-import { NavigationActions, StackActions } from 'react-navigation'
-import JPushModule from 'jpush-react-native'
-import Identicon from 'polkadot-identicon-react-native'
-import SInfo from 'react-native-sensitive-info'
-import { formatBalance } from '@polkadot/util'
-import { observer, inject } from 'mobx-react'
-import Right_menu from './secondary/RightMenu'
-import { ScreenWidth, ScreenHeight, axios } from '../../util/Common'
-import _updateConfig from '../../../update.json'
-import i18n from '../../locales/i18n'
-import polkadotAPI from '../../util/polkadotAPI.js'
-import Loading from '../../components/Loading'
-import LoadingUtil from '../../components/LoadingUtil'
-import DataRepository from '../../util/DataRepository'
-
-function judgeObj(obj) {
- for (let attr in obj) {
- return false
- }
- return true
-}
-@inject('rootStore')
-@observer
-class Assets extends Component {
- constructor(props) {
- super(props)
- this.state = {
- is: false,
- name: '0',
- address: '0',
- isfirst: 0,
- isrefresh: false,
- color: 'rgb(0,255,0)'
- }
- this.QR_Code = this.QR_Code.bind(this)
- this.Coin_details = this.Coin_details.bind(this)
- this.refresh = this.refresh.bind(this)
- this.Loading = this.Loading.bind(this)
- this.checkApi = this.checkApi.bind(this)
- this.interval = null
- this.handleAppStateChange = this.handleAppStateChange.bind(this)
- this.doUpdate = this.doUpdate.bind(this)
-
- this.animatedValue = new Animated.Value(0)
- this.movingMargin = this.animatedValue.interpolate({
- inputRange: [0, 1],
- outputRange: [ScreenWidth * 0.57, 0]
- })
- }
-
- // 跳转二维码页面
- // Jump to Qr_code page
- QR_Code() {
- this.props.navigation.navigate('QR_Code')
- }
-
- Coin_details() {
- this.props.navigation.navigate('Coin_details')
- }
-
- checkApi() {
- ;(async () => {
- new DataRepository()
- .fetchLocalRepository('localLanguage')
- .then(res => {
- i18n.locale = res
- })
- .catch(error => {
- i18n.locale = 'en'
- })
- if (judgeObj(this.props.rootStore.stateStore.API)) {
- LoadingUtil.showLoading()
- const api = await Api.create(new WsProvider(this.props.rootStore.stateStore.ENDPOINT))
- this.props.rootStore.stateStore.API = api
- LoadingUtil.dismissLoading()
- }
- })()
- }
-
- // 初始加载函数
- // Londing function
- Loading() {
- SInfo.getAllItems({
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- }).then(result => {
- if (JSON.stringify(result).length < 10) {
- const resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Create_Account' }, { t: this })]
- })
- this.props.navigation.dispatch(resetAction)
- } else {
- this.setState({
- isfirst: 1
- })
- this.props.rootStore.stateStore.refreshBefore = this.props.rootStore.stateStore.Account
- this.props.rootStore.stateStore.balanceIndex = 0
- this.props.rootStore.stateStore.Account = 0
- this.props.rootStore.stateStore.Accountnum = 0
- this.props.rootStore.stateStore.isfirst = 1
- this.props.rootStore.stateStore.Accounts = [{ account: 'NeedCreate', address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' }]
- this.props.rootStore.stateStore.balances = [{ address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx', balance: 0 }]
- if (Platform.OS == 'android') {
- // android
- let noticeTags = []
- for (let o in result) {
- this.props.rootStore.stateStore.Accounts.push({
- account: JSON.parse(result[o]).meta.name,
- address: JSON.parse(result[o]).address
- })
- this.props.rootStore.stateStore.Account++
- this.props.rootStore.stateStore.Accountnum++
- // 创建查询每个账户余额的进程
- // Create a process to query each account balance
- ;(async () => {
- const _address = o
- await polkadotAPI.freeBalance(_address, balance => {
- this.props.rootStore.stateStore.have = 0
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (item.address == _address) {
- this.props.rootStore.stateStore.have = 1
- this.props.rootStore.stateStore.balances[index].balance = balance
- }
- })
- if (this.props.rootStore.stateStore.have == 0) {
- this.props.rootStore.stateStore.balances.push({
- address: _address,
- balance
- })
- }
- })
- })()
- // 截取地址前25字符作为推送标签
- // Capture the first 25 characters of the address as the push tag
- noticeTags.push(o.slice(0, 25))
- }
- // 设置通知推送标签
- // Set notification push tages
- JPushModule.setTags(noticeTags, map => {
- if (map.errorCode === 0) {
- // console.warn('Set tags succeed, tags: ' + map.tags)
- } else {
- console.warn('Set tags failed, error code: ' + map.errorCode)
- }
- })
- } else {
- // ios
- let noticeTags = []
- result.map((item, index) => {
- item.map((item, index) => {
- // 添加用户到mobx
- // Add account to mobx
- this.props.rootStore.stateStore.Accounts.push({
- account: JSON.parse(item.value).meta.name,
- address: item.key
- })
- this.props.rootStore.stateStore.Account++
- this.props.rootStore.stateStore.Accountnum++
- // 创建查询每个账户的进程
- // Create a process to query each account balance
- ;(async () => {
- await polkadotAPI.freeBalance(item.key, balance => {
- const _address = item.key
- this.props.rootStore.stateStore.have = 0
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (item.address == _address) {
- this.props.rootStore.stateStore.have = 1
- this.props.rootStore.stateStore.balances[index].balance = balance
- }
- })
- if (this.props.rootStore.stateStore.have == 0) {
- this.props.rootStore.stateStore.balances.push({
- address: _address,
- balance
- })
- }
- })
- })()
- // 截取地址前25字符作为推送标签
- // Capture the first 25 characters of the address as the push tag
- noticeTags.push(item.key.slice(0, 25))
- })
- })
- // 设置通知推送标签
- // Set notification push tages
- JPushModule.setTags(noticeTags, map => {
- if (map.errorCode === 0) {
- // console.warn('Set tags succeed, tags: ' + map.tags)
- } else {
- console.warn('Set tags failed, error code: ' + map.errorCode)
- }
- })
- }
- }
- })
- setTimeout(() => {
- if (this.props.rootStore.stateStore.isfirst == 1) {
- this.props.rootStore.stateStore.Account = 1
- }
- this.props.rootStore.stateStore.Account =
- this.props.rootStore.stateStore.refreshBefore == 0 && this.props.rootStore.stateStore.isfirst == 1
- ? 1
- : this.props.rootStore.stateStore.refreshBefore
- if (this.props.rootStore.stateStore.Account != 0) {
- // Query Balance
- ;(async () => {
- const props = await polkadotAPI.properties()
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (
- item.address == this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- ) {
- this.props.rootStore.stateStore.balanceIndex = index
- }
- })
- formatBalance.setDefaults({
- decimals: props.get('tokenDecimals'),
- unit: props.get('tokenSymbol')
- })
- clearInterval(this.interval)
- this.interval = setInterval(async () => {
- let myDate = new Date()
- let blockdate = await polkadotAPI.timestampNow()
- let lastBlockTime = Number(myDate) - Number(blockdate)
- let a
- let b
- let c
- if (lastBlockTime > 120000) {
- a = 192
- b = 192
- c = 192
- } else {
- let colorPara = (lastBlockTime / 1000) * (255 / 18)
- a = 0
- b = 255
- c = 0
- for (let i = 0; i < colorPara; i++) {
- if (b >= 255 && a < 255) {
- a++
- }
- if (a >= 255) b--
- if (a >= 255 && b <= 0) {
- a = 255
- b = 0
- }
- }
- }
- this.setState({
- color: `rgb(${a},${b},${c})`
- })
- }, 500)
- })()
- }
-
- // 清除缓存
- // Clear the cache
- const REQUEST_URL = 'https://api.polkawallet.io:8080/tx_list_for_redis'
- const params = `{"user_address":"${this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}","pageNum":"1","pageSize":"10"}`
- axios(REQUEST_URL, params, 'post', true).then(() => {
- // 获取交易记录
- // Access to transaction records
- const REQUEST_URL = 'https://api.polkawallet.io:8080/tx_list'
- const params = `{"user_address":"${this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}","pageNum":"1","pageSize":"10"}`
- axios(REQUEST_URL, params).then(result => {
- this.props.rootStore.stateStore.hasNextPage = result.tx_list.hasNextPage
- this.props.rootStore.stateStore.transactions = result
- })
- })
- }, 100)
- }
-
- // 刷新
- // refresh
- refresh() {
- this.setState({
- isrefresh: true
- })
- this.checkApi()
- this.Loading()
- setTimeout(() => {
- this.setState({
- isrefresh: false
- })
- }, 2000)
- }
-
- handleAppStateChange(appState) {
- if (appState == 'background' && this.props.rootStore.stateStore.GestureState == 2) {
- const resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Gesture' })]
- })
- this.props.navigation.dispatch(resetAction)
- }
- }
-
- doUpdate(info) {
- downloadUpdate(info)
- .then(hash => {
- Alert.alert('', i18n.t('Profile.restartApp'), [
- {
- text: 'Yes',
- onPress: () => {
- switchVersion(hash)
- }
- },
- { text: 'No' },
- {
- text: i18n.t('Profile.nextTime'),
- onPress: () => {
- switchVersionLater(hash)
- }
- }
- ])
- })
- .catch(() => {
- Alert.alert('', i18n.t('Profile.UpdateFailed'))
- })
- }
-
- checkUpdate = () => {
- const { appKey } = _updateConfig[Platform.OS]
- checkUpdate(appKey)
- .then(info => {
- if (info.expired) {
- Alert.alert('', i18n.t('Profile.toAppStore'), [
- {
- text: 'OK',
- onPress: () => {
- // info.downloadUrl && Linking.openURL(info.downloadUrl)
- }
- }
- ])
- } else if (info.upToDate) {
- // Alert.alert('提示', '您的应用版本已是最新.');
- } else {
- Alert.alert(
- '',
- `${i18n.t('Profile.checkNewV') + info.name},${i18n.t('Profile.download')}\n${info.description}`,
- [
- {
- text: 'OK',
- onPress: () => {
- this.doUpdate(info)
- }
- }
- ]
- )
- }
- })
- .catch(() => {
- Alert.alert('', i18n.t('Profile.UpdateFailed'))
- })
- }
-
- // 侧边栏Modal显示
- // Modal display in the sidebar
- show() {
- this.setState({
- is: true
- })
- this.animatedValue.setValue(0)
- Animated.timing(this.animatedValue, {
- toValue: 1,
- duration: 600
- }).start()
- }
-
- // 侧边栏Modal隐藏
- // Modal hidden sidebar
- hide() {
- Animated.timing(this.animatedValue, {
- toValue: 0,
- duration: 600
- }).start()
- setTimeout(
- function() {
- this.changeAccount()
- this.setState({ is: false })
- }.bind(this),
- 600
- )
- }
-
- changeAccount() {
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (item.address == this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address) {
- this.props.rootStore.stateStore.balanceIndex = index
- }
- })
- }
-
- componentDidMount() {
- // 通过addListener开启监听,可以使用上面的四个属性
- // With addListener to enable listening, use the four properties above
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
- if (Platform.OS == 'android') {
- StatusBar.setBackgroundColor('#F14B79')
- }
- StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
- this.setState({})
- this.checkApi()
- this.Loading()
- this.changeAccount()
- })
- // 通知推送初始化
- // Notification push initialization
- JPushModule.initPush()
- JPushModule.addReceiveNotificationListener(this.receiveNotificationListener)
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- // Unlisten when the page disappears
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- componentWillMount() {
- this.checkApi()
- if (isFirstTime) {
- markSuccess()
- }
-
- if (Platform.OS == 'android') {
- StatusBar.setBackgroundColor('#F14B79')
- }
- StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
- AppState.addEventListener('change', this.handleAppStateChange)
- // 判断用户是否设置手势密码
- // Determines whether the user has set a gesture password
- AsyncStorage.getItem('Gesture').then(result => {
- if (result == null) {
- // 没有设置
- // Not set gesture password
- // this.checkUpdate ();
- this.props.rootStore.stateStore.GestureState = 0
- } else {
- // 设置了手势密码
- // The gesture password has been set
- if (this.props.rootStore.stateStore.GestureState != 2) {
- this.props.rootStore.stateStore.Gesture = result
- this.props.rootStore.stateStore.GestureState = 2
- const resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Gesture' })]
- })
- this.props.navigation.dispatch(resetAction)
- } else {
- // this.checkUpdate ();
- }
- }
- })
- this.Loading()
- }
-
- render() {
- return (
-
-
-
-
-
- {/* 导航栏 | avigation bar */}
-
-
-
-
-
-
-
-
-
-
- {/* 头部卡片信息 | Header card information */}
-
-
-
-
-
- {/* 用户名 | Account name */}
-
-
- {
- this.props.rootStore.stateStore.Accounts[
- this.props.rootStore.stateStore.isfirst == 0 ? 0 : this.props.rootStore.stateStore.Account
- ].account
- }
-
- {i18n.t('Assets.Account')}
-
-
-
-
- {/* 地址 | Address */}
-
-
- {
- this.props.rootStore.stateStore.Accounts[
- this.props.rootStore.stateStore.isfirst == 0 ? 0 : this.props.rootStore.stateStore.Account
- ].address
- }
-
-
- {/* 二维码 | Qr code */}
-
-
-
-
-
-
-
-
-
-
- {/* Assets list TIP */}
-
-
-
- {i18n.t('Assets.AssetsList')}
-
-
- {/* Assets list */}
-
-
-
-
-
-
-
-
- DOT
-
-
-
- {i18n.t('Assets.Alexander')}
-
-
-
-
- {formatBalance(
- this.props.rootStore.stateStore.balances[this.props.rootStore.stateStore.balanceIndex]
- .balance
- )}
-
-
-
-
-
-
-
-
- {
- this.setState({ is: false })
- }}
- transparent
- visible={this.state.is}
- >
-
- {
- this.hide()
- }}
- style={{
- width: ScreenWidth * 0.31,
- flex: 1,
- height: ScreenHeight
- }}
- />
-
-
-
-
-
-
- {
- global.mLoadingComponentRef = ref
- }}
- />
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- paddingBottom: 98,
- backgroundColor: '#F6F6F6'
- },
- navBar: {
- height: 44,
- width: ScreenWidth,
- justifyContent: 'center',
- alignItems: 'center',
- top: 0
- },
-
- navContent: {
- width: ScreenWidth,
- height: 157,
- alignItems: 'center',
- flex: 1,
- paddingTop: 15
- },
- TopBar: {
- borderRadius: 16,
- width: ScreenWidth - 40,
- height: 140,
- backgroundColor: 'white',
- marginTop: 32
- }
-})
-export default Assets
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ SafeAreaView,
+ StatusBar,
+ AsyncStorage,
+ AppState,
+ Alert,
+ Animated,
+ Platform,
+ ImageBackground,
+ StyleSheet,
+ Modal,
+ Linking,
+ InteractionManager
+} from 'react-native'
+import {
+ isFirstTime,
+ checkUpdate,
+ downloadUpdate,
+ switchVersion,
+ switchVersionLater,
+ markSuccess
+} from 'react-native-update'
+import Api from '@polkadot/api/promise'
+import WsProvider from '@polkadot/rpc-provider/ws'
+import { NavigationActions, StackActions } from 'react-navigation'
+import JPushModule from 'jpush-react-native'
+import Identicon from 'polkadot-identicon-react-native'
+import SInfo from 'react-native-sensitive-info'
+import { formatBalance } from '@polkadot/util'
+import { observer, inject } from 'mobx-react'
+import Right_menu from './secondary/RightMenu'
+import { ScreenWidth, ScreenHeight, axios } from '../../util/Common'
+import _updateConfig from '../../../update.json'
+import i18n from '../../locales/i18n'
+import polkadotAPI from '../../util/polkadotAPI.js'
+import Loading from '../../components/Loading'
+import LoadingUtil from '../../components/LoadingUtil'
+import DataRepository from '../../util/DataRepository'
+
+function judgeObj(obj) {
+ for (let attr in obj) {
+ return false
+ }
+ return true
+}
+@inject('rootStore')
+@observer
+class Assets extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ is: false,
+ name: '0',
+ address: '0',
+ isfirst: 0,
+ isrefresh: false,
+ color: 'rgb(0,255,0)'
+ }
+ this.QR_Code = this.QR_Code.bind(this)
+ this.Coin_details = this.Coin_details.bind(this)
+ this.refresh = this.refresh.bind(this)
+ this.Loading = this.Loading.bind(this)
+ this.checkApi = this.checkApi.bind(this)
+ this.interval = null
+ this.handleAppStateChange = this.handleAppStateChange.bind(this)
+ this.doUpdate = this.doUpdate.bind(this)
+
+ this.animatedValue = new Animated.Value(0)
+ this.movingMargin = this.animatedValue.interpolate({
+ inputRange: [0, 1],
+ outputRange: [ScreenWidth * 0.57, 0]
+ })
+ }
+
+ /**
+ * @description 跳转二维码页面|Jump to Qr_code page
+ */
+ QR_Code() {
+ this.props.navigation.navigate('QR_Code')
+ }
+
+ /**
+ * @description 跳转交易页面|Jump to Coin_details page
+ */
+ Coin_details() {
+ this.props.navigation.navigate('Coin_details')
+ }
+
+ /**
+ * @description 检查创建的API是否还存在|Check that the created API still exists
+ */
+ checkApi() {
+ ;(async () => {
+ new DataRepository()
+ .fetchLocalRepository('localLanguage')
+ .then(res => {
+ i18n.locale = res
+ })
+ .catch(error => {
+ i18n.locale = 'en'
+ })
+ if (judgeObj(this.props.rootStore.stateStore.API)) {
+ LoadingUtil.showLoading()
+ const api = await Api.create(new WsProvider(this.props.rootStore.stateStore.ENDPOINT))
+ this.props.rootStore.stateStore.API = api
+ LoadingUtil.dismissLoading()
+ }
+ })()
+ }
+
+ /**
+ * @description 初始加载函数|Londing function
+ */
+ Loading() {
+ SInfo.getAllItems({
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ }).then(result => {
+ if (JSON.stringify(result).length < 10) {
+ const resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Create_Account' }, { t: this })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ } else {
+ this.setState({
+ isfirst: 1
+ })
+ this.props.rootStore.stateStore.refreshBefore = this.props.rootStore.stateStore.Account
+ this.props.rootStore.stateStore.balanceIndex = 0
+ this.props.rootStore.stateStore.Account = 0
+ this.props.rootStore.stateStore.Accountnum = 0
+ this.props.rootStore.stateStore.isfirst = 1
+ this.props.rootStore.stateStore.Accounts = [{ account: 'NeedCreate', address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' }]
+ this.props.rootStore.stateStore.balances = [{ address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx', balance: 0 }]
+ if (Platform.OS == 'android') {
+ // android
+ let noticeTags = []
+ for (let o in result) {
+ this.props.rootStore.stateStore.Accounts.push({
+ account: JSON.parse(result[o]).meta.name,
+ address: JSON.parse(result[o]).address
+ })
+ this.props.rootStore.stateStore.Account++
+ this.props.rootStore.stateStore.Accountnum++
+ // 创建查询每个账户余额的进程
+ // Create a process to query each account balance
+ ;(async () => {
+ const _address = o
+ await polkadotAPI.freeBalance(_address, balance => {
+ this.props.rootStore.stateStore.have = 0
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (item.address == _address) {
+ this.props.rootStore.stateStore.have = 1
+ this.props.rootStore.stateStore.balances[index].balance = balance
+ }
+ })
+ if (this.props.rootStore.stateStore.have == 0) {
+ this.props.rootStore.stateStore.balances.push({
+ address: _address,
+ balance
+ })
+ }
+ })
+ })()
+ // 截取地址前25字符作为推送标签
+ // Capture the first 25 characters of the address as the push tag
+ noticeTags.push(o.slice(0, 25))
+ }
+ // 设置通知推送标签
+ // Set notification push tages
+ JPushModule.setTags(noticeTags, map => {
+ if (map.errorCode === 0) {
+ // console.warn('Set tags succeed, tags: ' + map.tags)
+ } else {
+ // console.warn('Set tags failed, error code: ' + map.errorCode)
+ }
+ })
+ } else {
+ // ios
+ let noticeTags = []
+ result.map((item, index) => {
+ item.map((item, index) => {
+ // 添加用户到mobx
+ // Add account to mobx
+ this.props.rootStore.stateStore.Accounts.push({
+ account: JSON.parse(item.value).meta.name,
+ address: item.key
+ })
+ this.props.rootStore.stateStore.Account++
+ this.props.rootStore.stateStore.Accountnum++
+ // 创建查询每个账户的进程
+ // Create a process to query each account balance
+ ;(async () => {
+ await polkadotAPI.freeBalance(item.key, balance => {
+ const _address = item.key
+ this.props.rootStore.stateStore.have = 0
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (item.address == _address) {
+ this.props.rootStore.stateStore.have = 1
+ this.props.rootStore.stateStore.balances[index].balance = balance
+ }
+ })
+ if (this.props.rootStore.stateStore.have == 0) {
+ this.props.rootStore.stateStore.balances.push({
+ address: _address,
+ balance
+ })
+ }
+ })
+ })()
+ // 截取地址前25字符作为推送标签
+ // Capture the first 25 characters of the address as the push tag
+ noticeTags.push(item.key.slice(0, 25))
+ })
+ })
+ // 设置通知推送标签
+ // Set notification push tages
+ JPushModule.setTags(noticeTags, map => {
+ if (map.errorCode === 0) {
+ // console.warn('Set tags succeed, tags: ' + map.tags)
+ } else {
+ // console.warn('Set tags failed, error code: ' + map.errorCode)
+ }
+ })
+ }
+ }
+ })
+ setTimeout(() => {
+ if (this.props.rootStore.stateStore.isfirst == 1) {
+ this.props.rootStore.stateStore.Account = 1
+ }
+ this.props.rootStore.stateStore.Account =
+ this.props.rootStore.stateStore.refreshBefore == 0 && this.props.rootStore.stateStore.isfirst == 1
+ ? 1
+ : this.props.rootStore.stateStore.refreshBefore
+ if (this.props.rootStore.stateStore.Account != 0) {
+ // Query Balance
+ ;(async () => {
+ const props = await polkadotAPI.properties()
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (
+ item.address == this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ ) {
+ this.props.rootStore.stateStore.balanceIndex = index
+ }
+ })
+ formatBalance.setDefaults({
+ decimals: props.get('tokenDecimals'),
+ unit: props.get('tokenSymbol')
+ })
+ clearInterval(this.interval)
+ this.interval = setInterval(async () => {
+ let myDate = new Date()
+ let blockdate = await polkadotAPI.timestampNow()
+ let lastBlockTime = Number(myDate) - Number(blockdate)
+ let a
+ let b
+ let c
+ if (lastBlockTime > 120000) {
+ a = 192
+ b = 192
+ c = 192
+ } else {
+ let colorPara = (lastBlockTime / 1000) * (255 / 18)
+ a = 0
+ b = 255
+ c = 0
+ for (let i = 0; i < colorPara; i++) {
+ if (b >= 255 && a < 255) {
+ a++
+ }
+ if (a >= 255) b--
+ if (a >= 255 && b <= 0) {
+ a = 255
+ b = 0
+ }
+ }
+ }
+ this.setState({
+ color: `rgb(${a},${b},${c})`
+ })
+ }, 500)
+ })()
+ }
+
+ // 清除缓存
+ // Clear the cache
+ const REQUEST_URL = 'https://api.polkawallet.io:8080/tx_list_for_redis'
+ const params = `{"user_address":"${this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}","pageNum":"1","pageSize":"10"}`
+ axios(REQUEST_URL, params, 'post', true).then(() => {
+ // 获取交易记录
+ // Access to transaction records
+ const REQUEST_URL = 'https://api.polkawallet.io:8080/tx_list'
+ const params = `{"user_address":"${this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}","pageNum":"1","pageSize":"10"}`
+ axios(REQUEST_URL, params).then(result => {
+ this.props.rootStore.stateStore.hasNextPage = result.tx_list.hasNextPage
+ this.props.rootStore.stateStore.transactions = result
+ })
+ })
+ }, 100)
+ }
+
+ /**
+ * @description 刷新|refresh
+ */
+ refresh() {
+ this.setState({
+ isrefresh: true
+ })
+ this.checkApi()
+ this.Loading()
+ setTimeout(() => {
+ this.setState({
+ isrefresh: false
+ })
+ }, 2000)
+ }
+
+ /**
+ * @description APP 前后台切换|APP front and background switching
+ * @param {String} appState 切换状态|Switch state
+ */
+ handleAppStateChange(appState) {
+ if (appState == 'background') {
+ this.props.rootStore.stateStore.api = {}
+ } else if (appState == 'active') {
+ this.checkApi()
+ }
+ if (appState == 'background' && this.props.rootStore.stateStore.GestureState == 2) {
+ const resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Gesture' })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ }
+ }
+
+ /**
+ * @description 更新app|Update the app
+ * @param {*} info 更新信息|update information
+ */
+ doUpdate(info) {
+ downloadUpdate(info)
+ .then(hash => {
+ Alert.alert('', i18n.t('Profile.restartApp'), [
+ {
+ text: 'Yes',
+ onPress: () => {
+ switchVersion(hash)
+ }
+ },
+ { text: 'No' },
+ {
+ text: i18n.t('Profile.nextTime'),
+ onPress: () => {
+ switchVersionLater(hash)
+ }
+ }
+ ])
+ })
+ .catch(() => {
+ // Alert.alert('', i18n.t('Profile.UpdateFailed'))
+ })
+ }
+
+ /**
+ * @description 检查更新|Check the update
+ */
+ checkUpdate = () => {
+ const { appKey } = _updateConfig[Platform.OS]
+ checkUpdate(appKey)
+ .then(info => {
+ if (info.expired) {
+ Alert.alert('', i18n.t('Profile.toAppStore'), [
+ {
+ test: 'No',
+ style: 'cancel'
+ },
+ {
+ text: 'Yes',
+ onPress: () => {
+ Linking.openURL('https://polkawallet.io/#download')
+ }
+ }
+ ])
+ } else if (info.upToDate) {
+ // Alert.alert('提示', '您的应用版本已是最新.');
+ } else {
+ Alert.alert(
+ '',
+ `${i18n.t('Profile.checkNewV') + info.name},${i18n.t('Profile.download')}\n${info.description}`,
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ this.doUpdate(info)
+ }
+ }
+ ]
+ )
+ }
+ })
+ .catch(() => {
+ // Alert.alert('', i18n.t('Profile.UpdateFailed'))
+ })
+ }
+
+ /**
+ * @description 侧边栏Modal显示|Modal display in the sidebar
+ */
+ show() {
+ this.setState({
+ is: true
+ })
+ this.animatedValue.setValue(0)
+ Animated.timing(this.animatedValue, {
+ toValue: 1,
+ duration: 500,
+ useNativeDriver: true
+ }).start()
+ }
+
+ /**
+ * @description 侧边栏Modal隐藏|Modal hidden sidebar
+ */
+ hide() {
+ Animated.timing(this.animatedValue, {
+ toValue: 0,
+ duration: 500,
+ useNativeDriver: true
+ }).start()
+ setTimeout(
+ function() {
+ this.changeAccount()
+ this.setState({ is: false })
+ }.bind(this),
+ 500
+ )
+ }
+
+ /**
+ * @description 切换账户|Switch account
+ */
+ changeAccount() {
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (item.address == this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address) {
+ this.props.rootStore.stateStore.balanceIndex = index
+ }
+ })
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ // 通过addListener开启监听,可以使用上面的四个属性
+ // With addListener to enable listening, use the four properties above
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
+ if (Platform.OS == 'android') {
+ StatusBar.setBackgroundColor('#F14B79')
+ }
+ StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
+ this.setState({})
+ this.checkApi()
+ this.Loading()
+ this.changeAccount()
+ })
+ // 通知推送初始化
+ // Notification push initialization
+ JPushModule.initPush()
+ JPushModule.addReceiveNotificationListener(this.receiveNotificationListener)
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ componentWillMount() {
+ InteractionManager.runAfterInteractions(() => {
+ this.checkApi()
+ if (isFirstTime) {
+ markSuccess()
+ }
+
+ if (Platform.OS == 'android') {
+ StatusBar.setBackgroundColor('#F14B79')
+ }
+ StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
+ AppState.addEventListener('change', this.handleAppStateChange)
+ // 判断用户是否设置手势密码
+ // Determines whether the user has set a gesture password
+ AsyncStorage.getItem('Gesture').then(result => {
+ if (result == null) {
+ // 没有设置
+ // Not set gesture password
+ this.checkUpdate()
+ this.props.rootStore.stateStore.GestureState = 0
+ } else {
+ // 设置了手势密码
+ // The gesture password has been set
+ if (this.props.rootStore.stateStore.GestureState != 2) {
+ this.props.rootStore.stateStore.Gesture = result
+ this.props.rootStore.stateStore.GestureState = 2
+ const resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Gesture' })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ } else {
+ this.checkUpdate()
+ }
+ }
+ })
+ this.Loading()
+ })
+ }
+
+ render() {
+ return (
+
+
+
+
+
+ {/* 导航栏 | avigation bar */}
+
+
+
+
+
+
+
+
+
+
+ {/* 头部卡片信息 | Header card information */}
+
+
+
+
+
+ {/* 用户名 | Account name */}
+
+
+ {
+ this.props.rootStore.stateStore.Accounts[
+ this.props.rootStore.stateStore.isfirst == 0 ? 0 : this.props.rootStore.stateStore.Account
+ ].account
+ }
+
+ {i18n.t('Assets.Account')}
+
+
+
+
+ {/* 地址 | Address */}
+
+
+ {
+ this.props.rootStore.stateStore.Accounts[
+ this.props.rootStore.stateStore.isfirst == 0 ? 0 : this.props.rootStore.stateStore.Account
+ ].address
+ }
+
+
+ {/* 二维码 | Qr code */}
+
+
+
+
+
+
+
+
+
+
+ {/* Assets list TIP */}
+
+
+
+ {i18n.t('Assets.AssetsList')}
+
+
+ {/* Assets list */}
+
+
+
+
+
+
+
+
+ DOT
+
+
+
+ {i18n.t('Assets.Alexander')}
+
+
+
+
+ {formatBalance(
+ this.props.rootStore.stateStore.balances[this.props.rootStore.stateStore.balanceIndex]
+ .balance
+ )}
+
+
+
+
+
+
+
+
+ {
+ this.setState({ is: false })
+ }}
+ transparent
+ visible={this.state.is}
+ >
+
+ {
+ this.hide()
+ }}
+ style={{
+ width: ScreenWidth * 0.31,
+ flex: 1,
+ height: ScreenHeight
+ }}
+ />
+
+
+
+
+
+
+ {
+ global.mLoadingComponentRef = ref
+ }}
+ />
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ paddingBottom: 98,
+ backgroundColor: '#F6F6F6'
+ },
+ navBar: {
+ height: 44,
+ width: ScreenWidth,
+ justifyContent: 'center',
+ alignItems: 'center',
+ top: 0
+ },
+
+ navContent: {
+ width: ScreenWidth,
+ height: 157,
+ alignItems: 'center',
+ flex: 1,
+ paddingTop: 15
+ },
+ TopBar: {
+ borderRadius: 16,
+ width: ScreenWidth - 40,
+ height: 140,
+ backgroundColor: 'white',
+ marginTop: 32
+ }
+})
+export default Assets
diff --git a/src/page/Assets/secondary/BackupAccount.js b/src/page/Assets/secondary/BackupAccount.js
index e1c5f53e..63a85f93 100755
--- a/src/page/Assets/secondary/BackupAccount.js
+++ b/src/page/Assets/secondary/BackupAccount.js
@@ -1,218 +1,232 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- Clipboard,
- StatusBar,
- SafeAreaView,
- ScrollView,
- Alert
-} from 'react-native'
-import { NavigationActions, StackActions } from 'react-navigation'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import Header from '../../../components/Header'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class BackupAccount extends Component {
- constructor(props) {
- super(props)
- this.state = {
- text: this.props.navigation.state.params.key,
- address: this.props.navigation.state.params.address
- }
- this.copy = this.copy.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Continue = this.Continue.bind(this)
- }
-
- // 点击取消
- // Click cancel
- Cancel() {
- // 创建查询每个账户的进程
- // Create a process to query each account
- ;(async () => {
- await polkadotAPI.freeBalance(this.state.address, balance => {
- let _address = this.state.address
- this.props.rootStore.stateStore.have = 0
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (item.address == _address) {
- this.props.rootStore.stateStore.have = 1
- this.props.rootStore.stateStore.balances[index].balance = balance
- }
- })
- if (this.props.rootStore.stateStore.have == 0) {
- this.props.rootStore.stateStore.balances.push({
- address: _address,
- balance: balance
- })
- }
- })
- })()
- this.props.navigation.navigate('Create_Account')
- }
-
- // 点击确认
- // Click Continue
- Continue() {
- // 创建查询每个账户的进程
- // Create a process to query each account
- ;(async () => {
- await polkadotAPI.freeBalance(this.state.address, balance => {
- let _address = this.state.address
- this.props.rootStore.stateStore.have = 0
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (item.address == _address) {
- this.props.rootStore.stateStore.have = 1
- this.props.rootStore.stateStore.balances[index].balance = balance
- }
- })
- if (this.props.rootStore.stateStore.have == 0) {
- this.props.rootStore.stateStore.balances.push({
- address: _address,
- balance: balance
- })
- }
- })
- })()
- let resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Tabbed_Navigation' })]
- })
- this.props.navigation.dispatch(resetAction)
- }
-
- // 拷贝
- // Click Copy
- async copy() {
- Alert.alert('', i18n.t('TAB.CopySuccess'))
- Clipboard.setString(this.state.text)
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
- {i18n.t('Assets.Warning')}
- {i18n.t('Assets.BeforeSafe')}
- {i18n.t('Assets.Restore')}
-
- {/* The key */}
-
- {this.state.text}
-
- {/* copy */}
-
-
-
-
-
-
-
-
-
- {i18n.t('TAB.Cancel')}
-
-
- {i18n.t('TAB.Continue')}
-
-
-
-
- )
- }
-}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- text: {
- paddingVertical: 20,
- fontSize: 20,
- fontWeight: 'bold',
- color: '#3E2D32'
- },
- textInput: {
- height: ScreenHeight / 8,
- flexDirection: 'row',
- alignItems: 'center'
- },
- textInputStyle: {
- height: ScreenHeight / 10,
- width: ScreenWidth * 0.75,
- borderWidth: 1,
- borderColor: 'grey',
- borderRadius: ScreenHeight / 100,
- paddingLeft: ScreenHeight / 100,
- fontSize: ScreenHeight / 40,
- paddingVertical: 0
- },
- image: {
- marginLeft: ScreenWidth * 0.025,
- height: ScreenWidth * 0.07,
- width: ScreenWidth * 0.07,
- resizeMode: 'contain'
- },
- chooseText: {
- fontSize: 18,
- color: 'white'
- },
- chooseView: {
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'center',
- borderRadius: 5,
- height: 49,
- width: (ScreenWidth - 50) / 2
- }
-})
-export default BackupAccount
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ Clipboard,
+ StatusBar,
+ SafeAreaView,
+ ScrollView,
+ Alert
+} from 'react-native'
+import { NavigationActions, StackActions } from 'react-navigation'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, doubleClick } from '../../../util/Common'
+import Header from '../../../components/Header'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class BackupAccount extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ text: this.props.navigation.state.params.key,
+ address: this.props.navigation.state.params.address
+ }
+ this.copy = this.copy.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Continue = this.Continue.bind(this)
+ }
+
+ /**
+ * @description 点击取消|Click cancel
+ */
+ Cancel() {
+ // 创建查询每个账户的进程
+ // Create a process to query each account
+ ;(async () => {
+ await polkadotAPI.freeBalance(this.state.address, balance => {
+ let _address = this.state.address
+ this.props.rootStore.stateStore.have = 0
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (item.address == _address) {
+ this.props.rootStore.stateStore.have = 1
+ this.props.rootStore.stateStore.balances[index].balance = balance
+ }
+ })
+ if (this.props.rootStore.stateStore.have == 0) {
+ this.props.rootStore.stateStore.balances.push({
+ address: _address,
+ balance: balance
+ })
+ }
+ })
+ })()
+ this.props.navigation.navigate('Create_Account')
+ }
+
+ /**
+ * @description 点击确认|Click Continue
+ */
+ Continue() {
+ // 创建查询每个账户的进程
+ // Create a process to query each account
+ ;(async () => {
+ await polkadotAPI.freeBalance(this.state.address, balance => {
+ let _address = this.state.address
+ this.props.rootStore.stateStore.have = 0
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (item.address == _address) {
+ this.props.rootStore.stateStore.have = 1
+ this.props.rootStore.stateStore.balances[index].balance = balance
+ }
+ })
+ if (this.props.rootStore.stateStore.have == 0) {
+ this.props.rootStore.stateStore.balances.push({
+ address: _address,
+ balance: balance
+ })
+ }
+ })
+ })()
+ let resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Tabbed_Navigation' })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ }
+
+ /**
+ * @description 拷贝|Click Copy
+ */
+ async copy() {
+ Alert.alert('', i18n.t('TAB.CopySuccess'))
+ Clipboard.setString(this.state.text)
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+ {i18n.t('Assets.Warning')}
+ {i18n.t('Assets.BeforeSafe')}
+ {i18n.t('Assets.Restore')}
+
+ {/* The key */}
+
+ {this.state.text}
+
+ {/* copy */}
+ {
+ doubleClick(this.copy)
+ }}
+ activeOpacity={0.7}
+ style={{ width: 30 }}
+ >
+
+
+
+
+
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+
+ {i18n.t('TAB.Continue')}
+
+
+
+
+ )
+ }
+}
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ text: {
+ paddingVertical: 20,
+ fontSize: 20,
+ fontWeight: 'bold',
+ color: '#3E2D32'
+ },
+ textInput: {
+ height: ScreenHeight / 8,
+ flexDirection: 'row',
+ alignItems: 'center'
+ },
+ textInputStyle: {
+ height: ScreenHeight / 10,
+ width: ScreenWidth * 0.75,
+ borderWidth: 1,
+ borderColor: 'grey',
+ borderRadius: ScreenHeight / 100,
+ paddingLeft: ScreenHeight / 100,
+ fontSize: ScreenHeight / 40,
+ paddingVertical: 0
+ },
+ image: {
+ marginLeft: ScreenWidth * 0.025,
+ height: ScreenWidth * 0.07,
+ width: ScreenWidth * 0.07,
+ resizeMode: 'contain'
+ },
+ chooseText: {
+ fontSize: 18,
+ color: 'white'
+ },
+ chooseView: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'center',
+ borderRadius: 5,
+ height: 49,
+ width: (ScreenWidth - 50) / 2
+ }
+})
+export default BackupAccount
diff --git a/src/page/Assets/secondary/Camera.js b/src/page/Assets/secondary/Camera.js
index f6739299..74ec9007 100755
--- a/src/page/Assets/secondary/Camera.js
+++ b/src/page/Assets/secondary/Camera.js
@@ -1,140 +1,142 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-20 21:01:02
- */
-import React, { Component } from 'react'
-import { StyleSheet, Text, View, TouchableOpacity, StatusBar, SafeAreaView, Platform } from 'react-native'
-import { QRscanner } from 'react-native-qr-scanner'
-import { observer, inject } from 'mobx-react'
-import { NavigationActions, StackActions } from 'react-navigation'
-import { ScreenHeight, ScannerType } from '../../../util/Common'
-import Header from '../../../components/Header'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Scanner extends Component {
- constructor(props) {
- super(props)
- this.state = {
- flashMode: false,
- zoom: 0.2
- }
- this.back = this.back.bind(this)
- }
-
- // 点击返回
- // Click back
- back() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- render() {
- return (
-
-
-
-
-
- )
- }
-
- // 页面底部
- // Bottom of the page
- bottomView = () => {
- return (
-
- this.setState({ flashMode: !this.state.flashMode })}
- >
- {i18n.t('Assets.Flashlight')}
-
-
- )
- }
-
- // 扫描到信息
- // The info from Scan Qr
- onRead = res => {
- let QRdata = ScannerType(res.data)
- if (this.props.rootStore.stateStore.tocamera == 0) {
- // Assets界面进来的
- // From Assets page
- this.props.rootStore.stateStore.iscamera = 1
- this.props.rootStore.stateStore.t_address = QRdata.data
- let resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Transfer' })]
- })
- this.props.navigation.dispatch(resetAction)
- }
- if (this.props.rootStore.stateStore.tocamera == 1) {
- // transfer界面进来的
- // From transfer page
- this.props.rootStore.stateStore.iscamera = 1
- this.props.rootStore.stateStore.t_address = QRdata.data
- this.props.navigation.navigate('Transfer')
- }
- if (this.props.rootStore.stateStore.tocamera == 2) {
- // 通讯录界面进来的
- // From Add_address page
- this.props.rootStore.stateStore.iscamera = 1
- this.props.rootStore.stateStore.QRaddress = QRdata.data
- this.props.navigation.navigate('Add_address')
- }
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: '#000'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- }
-})
-export default Scanner
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { StyleSheet, Text, View, TouchableOpacity, StatusBar, SafeAreaView, Platform } from 'react-native'
+import { QRscanner } from 'react-native-qr-scanner'
+import { observer, inject } from 'mobx-react'
+import { NavigationActions, StackActions } from 'react-navigation'
+import { ScreenHeight, ScannerType } from '../../../util/Common'
+import Header from '../../../components/Header'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Scanner extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ flashMode: false,
+ zoom: 0.2
+ }
+ this.back = this.back.bind(this)
+ }
+
+ /**
+ * @description 点击返回|Click back
+ */
+ back() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ render() {
+ return (
+
+
+
+
+
+ )
+ }
+
+ // 页面底部
+ // Bottom of the page
+ bottomView = () => {
+ return (
+
+ this.setState({ flashMode: !this.state.flashMode })}
+ >
+ {i18n.t('Assets.Flashlight')}
+
+
+ )
+ }
+
+ // 扫描到信息
+ // The info from Scan Qr
+ onRead = res => {
+ let QRdata = ScannerType(res.data)
+ if (this.props.rootStore.stateStore.tocamera == 0) {
+ // Assets界面进来的
+ // From Assets page
+ this.props.rootStore.stateStore.iscamera = 1
+ this.props.rootStore.stateStore.t_address = QRdata.data
+ let resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Transfer' })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ }
+ if (this.props.rootStore.stateStore.tocamera == 1) {
+ // transfer界面进来的
+ // From transfer page
+ this.props.rootStore.stateStore.iscamera = 1
+ this.props.rootStore.stateStore.t_address = QRdata.data
+ this.props.navigation.navigate('Transfer')
+ }
+ if (this.props.rootStore.stateStore.tocamera == 2) {
+ // 通讯录界面进来的
+ // From Add_address page
+ this.props.rootStore.stateStore.iscamera = 1
+ this.props.rootStore.stateStore.QRaddress = QRdata.data
+ this.props.navigation.navigate('Add_address')
+ }
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: '#000'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ }
+})
+export default Scanner
diff --git a/src/page/Assets/secondary/CoinDetails.js b/src/page/Assets/secondary/CoinDetails.js
index 27330ded..67a7c78c 100755
--- a/src/page/Assets/secondary/CoinDetails.js
+++ b/src/page/Assets/secondary/CoinDetails.js
@@ -1,487 +1,508 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- Text,
- TouchableOpacity,
- Image,
- ScrollView,
- RefreshControl,
- Platform,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import Echarts from 'native-echarts'
-import moment from 'moment/moment'
-
-import { formatBalance } from '@polkadot/util'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, axios } from '../../../util/Common'
-import Header from '../../../components/Header'
-import CoinRow from '../../../components/CoinRow'
-import i18n from '../../../locales/i18n'
-
-const titlebottoms = ['All', 'Out', 'In']
-@inject('rootStore')
-@observer
-class CoinDetails extends Component {
- constructor(props) {
- super(props)
- this.state = {
- isrefresh: false,
- isfirst: 0,
- titlebottom: 1,
- pageNum: 1,
- hasNextPage: false,
- transactions: [],
- StakingOption: {
- title: {
- text: i18n.t('Assets.AssetsOption'),
- textStyle: {
- color: '#3E2D32',
- fontSize: 16
- },
- padding: [0, 0, 0, 0]
- },
- tooltip: {},
- legend: {
- data: ['']
- },
- grid: {
- left: 5
- },
- xAxis: {
- axisLine: {
- show: false
- },
- data: []
- },
- yAxis: {
- axisLine: {
- show: false
- },
- position: 'right'
- },
- color: ['#FF5080'],
- series: [
- {
- type: 'line',
- smooth: true,
- data: []
- }
- ]
- }
- }
- this.back = this.back.bind(this)
- this.Send = this.Send.bind(this)
- this.Receive = this.Receive.bind(this)
- this.Loadmore = this.Loadmore.bind(this)
- this.refresh = this.refresh.bind(this)
- this.Load = this.Load.bind(this)
- }
-
- // 点击返回
- // Click back
- back() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 加载信息
- // Loding
- Load() {
- // 清除缓存
- // Clear the cache
- let REQUEST_URL = 'https://api.polkawallet.io:8080/tx_list_for_redis'
- let params =
- '{"user_address":"' +
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address +
- '","pageNum":"1","pageSize":"10"}'
- axios(REQUEST_URL, params, 'post', true)
- .then(() => {
- this.LoadTxList()
- })
- .catch()
- this.GetStakingOption(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
- }
-
- // 加载TXList
- LoadTxList(pageNum = 1) {
- // 获取交易记录
- // Access to transaction records
- let REQUEST_URL = 'https://api.polkawallet.io:8080/tx_list'
- let params = `{"user_address":"${this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}","pageNum":${pageNum},"pageSize":"10"}`
- axios(REQUEST_URL, params)
- .then(result => {
- let transactions = [...this.state.transactions, ...result.tx_list.list]
- if (pageNum == 1) {
- transactions = [...result.tx_list.list]
- }
- this.setState({
- hasNextPage: result.tx_list.hasNextPage,
- transactions
- })
- })
- .catch()
- }
-
- // 刷新
- refresh() {
- this.setState({
- isrefresh: true,
- transactions: []
- })
- setTimeout(() => {
- this.Load()
- }, 200)
- this.setState({
- isrefresh: false
- })
- }
-
- // TXList 加载更多
- Loadmore() {
- this.setState(
- {
- pageNum: this.state.pageNum + 1
- },
- () => {
- this.LoadTxList(this.state.pageNum)
- }
- )
- }
-
- GetStakingOption(address) {
- // 获取选中账户折线图数据
- // Gets the selected account chart data
- let REQUEST_URL = 'https://api.polkawallet.io:8080/tx_money_date'
- let params =
- '{"user_address":"' +
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address +
- '","UTCdate":"' +
- moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss') +
- '"}'
- axios(REQUEST_URL, params)
- .then(result => {
- let _StakingOption = {
- title: {
- text: i18n.t('Assets.AssetsOption'),
- textStyle: {
- color: '#3E2D32',
- fontSize: 16
- },
- padding: [0, 0, 0, 0]
- },
- tooltip: {},
- legend: {
- data: ['']
- },
- grid: {
- left: 5
- },
- xAxis: {
- axisLine: {
- show: false
- },
- data: []
- },
- yAxis: {
- axisLine: {
- show: false
- },
- position: 'right'
- },
- color: ['#FF5080'],
- series: [
- {
- type: 'line',
- smooth: true,
- data: []
- }
- ]
- }
- _StakingOption.xAxis.data = []
- _StakingOption.series[0].data = []
- result.map((item, index) => {
- _StakingOption.xAxis.data.push(item.time.substring(5, 7) + '/' + item.time.substring(8, 10))
- _StakingOption.series[0].data.push(item.money)
- })
- let max = 0
- for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
- if (_StakingOption.series[0].data[i] > max) {
- max = _StakingOption.series[0].data[i]
- }
- }
- let power =
- formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).power +
- formatBalance.getDefaults().decimals
- let unit = formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).text
- for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
- _StakingOption.series[0].data[i] = (_StakingOption.series[0].data[i] / Number(Math.pow(10, power))).toFixed(3)
- }
- _StakingOption.title.text = i18n.t('Assets.AssetsOption_new') + ' ( ' + unit + ' )'
- this.setState({
- StakingOption: _StakingOption
- })
- })
- .catch()
- }
-
- // 点击send按钮
- // Click Send
- Send() {
- this.props.navigation.navigate('Transfer')
- }
-
- // 点击Receive按钮
- // Click Receive
- Receive() {
- this.props.navigation.navigate('QR_Code')
- }
-
- componentDidMount() {
- // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
- // Start listening through addListener, didFocus RN lifecycle, page gets focus
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
- this.Load()
- })
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- // Unlisten when the page disappears
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- render() {
- return (
-
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
- {/* The line chart */}
-
-
-
-
- {/* 次标题 | Subheading */}
-
- {titlebottoms.map((item, index) => {
- return (
- {
- this.setState({
- titlebottom: index + 1
- })
- }}
- >
-
- {item}
-
-
- )
- })}
-
-
- {/* Sliding table */}
-
- }
- >
- {this.state.transactions.map((item, index) => {
- return this.state.titlebottom == 1 ? (
- // All
-
- ) : this.state.titlebottom == 2 && item.tx_type == 'Send' ? (
- // Out
-
- ) : this.state.titlebottom == 3 && item.tx_type == 'Receive' ? (
- // in
-
- ) : (
-
- )
- })}
- {this.state.hasNextPage ? (
-
- {i18n.t('TAB.loadMore')}
-
- ) : (
-
- {i18n.t('TAB.Bottom')}
-
- )}
-
-
-
-
-
- {/* Send or Receive */}
-
-
-
- {i18n.t('Assets.send')}
-
-
-
-
- {i18n.t('TAB.Receive')}
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- SorR_View: {
- height: ScreenHeight / 15,
- width: ScreenWidth / 2.015,
- borderRadius: ScreenHeight / 150,
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'center'
- },
- SorR_Image: {
- height: ScreenHeight / 33,
- width: ScreenHeight / 33,
- resizeMode: 'contain'
- },
- SorR_Text: {
- color: 'white',
- fontSize: ScreenWidth / 25,
- fontWeight: '500',
- marginLeft: ScreenWidth / 30
- },
- value: {
- marginRight: ScreenWidth / 20,
- fontSize: 16,
- color: '#3E2D32'
- }
-})
-export default CoinDetails
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ Text,
+ TouchableOpacity,
+ Image,
+ ScrollView,
+ RefreshControl,
+ Platform,
+ StatusBar,
+ SafeAreaView,
+ InteractionManager
+} from 'react-native'
+import Echarts from 'native-echarts'
+import moment from 'moment/moment'
+
+import { formatBalance } from '@polkadot/util'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, axios } from '../../../util/Common'
+import Header from '../../../components/Header'
+import CoinRow from '../../../components/CoinRow'
+import i18n from '../../../locales/i18n'
+
+const titlebottoms = ['All', 'Out', 'In']
+@inject('rootStore')
+@observer
+class CoinDetails extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ isrefresh: false,
+ isfirst: 0,
+ titlebottom: 1,
+ pageNum: 1,
+ hasNextPage: false,
+ transactions: [],
+ StakingOption: {
+ title: {
+ text: i18n.t('Assets.AssetsOption'),
+ textStyle: {
+ color: '#3E2D32',
+ fontSize: 16
+ },
+ padding: [0, 0, 0, 0]
+ },
+ tooltip: {},
+ legend: {
+ data: ['']
+ },
+ grid: {
+ left: 5
+ },
+ xAxis: {
+ axisLine: {
+ show: false
+ },
+ data: []
+ },
+ yAxis: {
+ axisLine: {
+ show: false
+ },
+ position: 'right'
+ },
+ color: ['#FF5080'],
+ series: [
+ {
+ type: 'line',
+ smooth: true,
+ data: []
+ }
+ ]
+ }
+ }
+ this.back = this.back.bind(this)
+ this.Send = this.Send.bind(this)
+ this.Receive = this.Receive.bind(this)
+ this.Loadmore = this.Loadmore.bind(this)
+ this.refresh = this.refresh.bind(this)
+ this.Load = this.Load.bind(this)
+ }
+
+ /**
+ * @description 点击返回|Click back
+ */
+ back() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 加载信息|Loding
+ */
+ Load() {
+ // 清除缓存
+ // Clear the cache
+ let REQUEST_URL = 'https://api.polkawallet.io:8080/tx_list_for_redis'
+ let params =
+ '{"user_address":"' +
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address +
+ '","pageNum":"1","pageSize":"10"}'
+ axios(REQUEST_URL, params, 'post', true)
+ .then(() => {
+ this.LoadTxList()
+ })
+ .catch()
+ this.GetStakingOption(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
+ }
+
+ /**
+ * @description 加载交易列表|Load transaction list
+ * @param {Num} pageNum 加载的页数|Page number to load
+ */
+ LoadTxList(pageNum = 1) {
+ // 获取交易记录
+ // Access to transaction records
+ let REQUEST_URL = 'https://api.polkawallet.io:8080/tx_list'
+ let params = `{"user_address":"${this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}","pageNum":${pageNum},"pageSize":"10"}`
+ axios(REQUEST_URL, params)
+ .then(result => {
+ let transactions = [...this.state.transactions, ...result.tx_list.list]
+ if (pageNum == 1) {
+ transactions = [...result.tx_list.list]
+ }
+ this.setState({
+ hasNextPage: result.tx_list.hasNextPage,
+ transactions
+ })
+ })
+ .catch()
+ }
+
+ /**
+ * @description 刷新|refresh
+ */
+ refresh() {
+ this.setState({
+ isrefresh: true,
+ transactions: []
+ })
+ setTimeout(() => {
+ this.Load()
+ }, 200)
+ this.setState({
+ isrefresh: false
+ })
+ }
+
+ /**
+ * @description 交易记录加载更多|Load more transaction record
+ */
+ Loadmore() {
+ this.setState(
+ {
+ pageNum: this.state.pageNum + 1
+ },
+ () => {
+ this.LoadTxList(this.state.pageNum)
+ }
+ )
+ }
+
+ /**
+ * @description 获取折线图数据|Gets chart data
+ */
+ GetStakingOption() {
+ // 获取选中账户折线图数据
+ // Gets the selected account chart data
+ let REQUEST_URL = 'https://api.polkawallet.io:8080/tx_money_date'
+ let params =
+ '{"user_address":"' +
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address +
+ '","UTCdate":"' +
+ moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss') +
+ '"}'
+ axios(REQUEST_URL, params)
+ .then(result => {
+ let _StakingOption = {
+ title: {
+ text: i18n.t('Assets.AssetsOption'),
+ textStyle: {
+ color: '#3E2D32',
+ fontSize: 16
+ },
+ padding: [0, 0, 0, 0]
+ },
+ tooltip: {},
+ legend: {
+ data: ['']
+ },
+ grid: {
+ left: 5
+ },
+ xAxis: {
+ axisLine: {
+ show: false
+ },
+ data: []
+ },
+ yAxis: {
+ axisLine: {
+ show: false
+ },
+ position: 'right'
+ },
+ color: ['#FF5080'],
+ series: [
+ {
+ type: 'line',
+ smooth: true,
+ data: []
+ }
+ ]
+ }
+ _StakingOption.xAxis.data = []
+ _StakingOption.series[0].data = []
+ result.map((item, index) => {
+ _StakingOption.xAxis.data.push(item.time.substring(5, 7) + '/' + item.time.substring(8, 10))
+ _StakingOption.series[0].data.push(item.money)
+ })
+ let max = 0
+ for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
+ if (_StakingOption.series[0].data[i] > max) {
+ max = _StakingOption.series[0].data[i]
+ }
+ }
+ let power =
+ formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).power +
+ formatBalance.getDefaults().decimals
+ let unit = formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).text
+ for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
+ _StakingOption.series[0].data[i] = (_StakingOption.series[0].data[i] / Number(Math.pow(10, power))).toFixed(3)
+ }
+ _StakingOption.title.text = i18n.t('Assets.AssetsOption_new') + ' ( ' + unit + ' )'
+ this.setState({
+ StakingOption: _StakingOption
+ })
+ })
+ .catch()
+ }
+
+ /**
+ * @description 点击send按钮 跳转页面|Click Send
+ */
+ Send() {
+ this.props.navigation.navigate('Transfer')
+ }
+
+ /**
+ * @description 点击Receive按钮 跳转页面|Click Receive
+ */
+ Receive() {
+ this.props.navigation.navigate('QR_Code')
+ }
+
+ componentDidMount() {
+ // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
+ // Start listening through addListener, didFocus RN lifecycle, page gets focus
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
+ InteractionManager.runAfterInteractions(() => {
+ this.Load()
+ })
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ render() {
+ return (
+
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+ {/* The line chart */}
+
+
+
+
+ {/* 次标题 | Subheading */}
+
+ {titlebottoms.map((item, index) => {
+ return (
+ {
+ this.setState({
+ titlebottom: index + 1
+ })
+ }}
+ >
+
+ {item}
+
+
+ )
+ })}
+
+
+ {/* Sliding table */}
+
+ }
+ >
+ {this.state.transactions.map((item, index) => {
+ return this.state.titlebottom == 1 ? (
+ // All
+
+ ) : this.state.titlebottom == 2 && item.tx_type == 'Send' ? (
+ // Out
+
+ ) : this.state.titlebottom == 3 && item.tx_type == 'Receive' ? (
+ // in
+
+ ) : (
+
+ )
+ })}
+ {this.state.hasNextPage ? (
+
+ {i18n.t('TAB.loadMore')}
+
+ ) : (
+
+ {i18n.t('TAB.Bottom')}
+
+ )}
+
+
+
+
+
+ {/* Send or Receive */}
+
+
+
+ {i18n.t('Assets.send')}
+
+
+
+
+ {i18n.t('TAB.Receive')}
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ SorR_View: {
+ height: ScreenHeight / 15,
+ width: ScreenWidth / 2.015,
+ borderRadius: ScreenHeight / 150,
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'center'
+ },
+ SorR_Image: {
+ height: ScreenHeight / 33,
+ width: ScreenHeight / 33,
+ resizeMode: 'contain'
+ },
+ SorR_Text: {
+ color: 'white',
+ fontSize: ScreenWidth / 25,
+ fontWeight: '500',
+ marginLeft: ScreenWidth / 30
+ },
+ value: {
+ marginRight: ScreenWidth / 20,
+ fontSize: 16,
+ color: '#3E2D32'
+ }
+})
+export default CoinDetails
diff --git a/src/page/Assets/secondary/CreateAccount.js b/src/page/Assets/secondary/CreateAccount.js
index c599553a..db6d3681 100755
--- a/src/page/Assets/secondary/CreateAccount.js
+++ b/src/page/Assets/secondary/CreateAccount.js
@@ -1,712 +1,732 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-21 21:33:46
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- TextInput,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import Identicon from 'polkadot-identicon-react-native'
-import { formatBalance, hexToU8a, isHex, stringToU8a, u8aToHex } from '@polkadot/util'
-import { NavigationActions, StackActions } from 'react-navigation'
-import SInfo from 'react-native-sensitive-info'
-import Keyring from '@polkadot/keyring'
-import { randomAsU8a, mnemonicGenerate } from '@polkadot/util-crypto'
-
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-import RNPicker from '../../../components/RNPicker'
-
-const keyring = new Keyring()
-
-@inject('rootStore')
-@observer
-class CreateAccount extends Component {
- constructor(props) {
- super(props)
- this.json
- this.pair
- this.state = {
- way: 'Mnemonic',
- way_change: 'Mnemonic',
- isModel: false,
- israndom: 1,
- keyrandom: '',
- key: '',
- name: '',
- password: '',
- passwordErepeat: '',
- address: 'xxxxxxxxxxxxxxxxxxxxxxxx',
- islookpwd: false,
- ispwd: 0,
- ispwd2: 0,
- balance: 0
- }
- this.Save_Account = this.Save_Account.bind(this)
- this.onChangekey = this.onChangekey.bind(this)
- this.onChangename = this.onChangename.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.Modify_way = this.Modify_way.bind(this)
- this.Reset = this.Reset.bind(this)
- this.onChangpasswordErepeat = this.onChangpasswordErepeat.bind(this)
- }
-
- // 页面加载
- // Page load
- componentWillMount() {
- ;(async () => {
- let key = mnemonicGenerate()
- this.pair = keyring.addFromMnemonic(key)
- this.setState({
- key: key,
- address: this.pair.address()
- })
- const props = await polkadotAPI.properties()
- formatBalance.setDefaults({
- decimals: props.get('tokenDecimals'),
- unit: props.get('tokenSymbol')
- })
- })()
- }
-
- // 切换单位
- // Switching unit
- Modify_way(way_change) {
- this.setState({
- isModel: false,
- way: way_change,
- way_change: way_change
- })
- let key
- if (way_change == 'Keystore') {
- this.setState({
- key: '',
- address: ''
- })
- return
- } else if (way_change == 'Mnemonic') {
- key = mnemonicGenerate()
- } else if (way_change == 'Mnemonic24') {
- key = mnemonicGenerate(24)
- } else {
- key = u8aToHex(randomAsU8a())
- }
- this.pair = keyring.addFromMnemonic(key)
- this.setState({
- key: key,
- address: this.pair.address()
- })
- }
-
- // key 输入框发生改变
- // The key input box has changed
- onChangekey(Changekey) {
- let tag = true
- let address = ''
- if (this.state.way == 'Mnemonic' || this.state.way == 'Mnemonic24') {
- try {
- tag = true
- this.pair = keyring.addFromMnemonic(Changekey)
- address = this.pair.address()
- this.setState({
- key: Changekey,
- address: this.pair.address()
- })
- } catch (e) {
- tag = false
- this.setState({
- key: Changekey,
- address: 'xxxxxxxxxxxxxxxxxxxxxxxx'
- })
- }
- } else if (this.state.way == 'Raw Seed') {
- try {
- tag = true
- if (isHex(Changekey) && Changekey.length === 66) {
- let SEEDu8a = hexToU8a(Changekey)
- this.pair = keyring.addFromSeed(SEEDu8a)
- address = this.pair.address()
- this.setState({
- key: Changekey,
- address: this.pair.address()
- })
- } else if (Changekey.length <= 32) {
- let SEED = Changekey.padEnd(32, ' ')
- let SEEDu8a = stringToU8a(SEED)
- this.pair = keyring.addFromSeed(SEEDu8a)
- address = this.pair.address()
- this.setState({
- key: Changekey,
- address: this.pair.address()
- })
- } else {
- tag = false
- this.setState({
- key: Changekey,
- address: 'xxxxxxxxxxxxxxxxxxxxxxxx'
- })
- }
- } catch (e) {
- tag = false
- this.setState({
- key: Changekey,
- address: 'xxxxxxxxxxxxxxxxxxxxxxxx'
- })
- }
- } else {
- try {
- tag = true
- address = JSON.parse(Changekey).address
- this.setState({
- key: Changekey,
- address: JSON.parse(Changekey).address
- })
- } catch (e) {
- this.setState({
- key: Changekey,
- address: 'xxxxxxxxxxxxxxxxxxxxxxxx'
- })
- tag = false
- }
- }
- if (tag) {
- ;(async () => {
- let balance = await polkadotAPI.freeBalance(address)
- this.setState({ balance: balance })
- })()
- }
- }
-
- // 姓名更改
- // The name has been changed
- onChangename(Changename) {
- this.setState({
- name: Changename
- })
- }
-
- // 密码更改
- // The password has been changed
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- if (Changepassword != '') {
- this.setState({ ispwd: 1 })
- }
- if (Changepassword == '') {
- this.setState({ ispwd: 0 })
- }
- }
-
- // 第二次重复密码更改
- // The repeat password has been changed
- onChangpasswordErepeat(Changepassword) {
- this.setState({
- passwordErepeat: Changepassword
- })
- if (Changepassword != this.state.password) {
- this.setState({ ispwd2: 0 })
- }
- if (Changepassword == this.state.password) {
- this.setState({ ispwd2: 1 })
- }
- }
-
- // 点击重置
- // Click Reset
- Reset() {
- let key
- if (this.state.way == 'Keystore') {
- this.setState({
- key: '',
- address: '',
- balance: 0
- })
- return
- } else if (this.state.way === 'Mnemonic') {
- key = mnemonicGenerate()
- } else if (this.state.way === 'Mnemonic24') {
- key = mnemonicGenerate(24)
- } else {
- key = u8aToHex(randomAsU8a())
- }
- this.pair = keyring.addFromMnemonic(key)
- this.setState({
- key: key,
- address: this.pair.address()
- })
- }
-
- // 点击保存
- // Click Save
- Save_Account() {
- if (this.state.name == '' && this.state.way != 'Keystore') {
- return Alert.alert('', i18n.t('Assets.EnterName'))
- }
- if (this.state.password == '' || this.state.passwordErepeat == '') {
- Alert.alert('', i18n.t('Assets.EnterPassword'))
- } else {
- if (this.state.password != this.state.passwordErepeat) {
- Alert.alert('', i18n.t('Assets.CheckPassword'))
- } else {
- if (this.state.address == 'xxxxxxxxxxxxxxxxxxxxxxxx' || this.state.address == '') {
- return Alert.alert('', i18n.t('TAB.enterInformation'))
- }
- // 开始校验密码
- // Start checking password
- SInfo.getItem(this.state.address, {
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- }).then(result => {
- if (result == null) {
- if (this.state.way == 'Keystore') {
- // 导入key 校验密码
- // Import key check password
- let loadPair = keyring.addFromJson(JSON.parse(this.state.key))
- try {
- loadPair.decodePkcs8(this.state.password)
- } catch (error) {
- Alert.alert(
- '',
- i18n.t('TAB.PasswordMistake'),
- [
- {
- text: 'OK',
- onPress: () => {}
- }
- ],
- { cancelable: false }
- )
- }
- loadPair.isLocked()
- ? '' // 校验成功 | Checking success
- : SInfo.setItem(this.state.address, this.state.key, {
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- })
- this.props.rootStore.stateStore.isfirst = 1
- this.props.rootStore.stateStore.Accounts.push({
- account: JSON.parse(this.state.key).meta.name,
- address: this.state.address
- })
- this.props.rootStore.stateStore.Accountnum++
- this.props.rootStore.stateStore.Account = this.props.rootStore.stateStore.Accountnum
- this.props.rootStore.stateStore.balances.push({
- address: this.state.address,
- balance: this.state.balance
- })
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (
- item.address ==
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- ) {
- this.props.rootStore.stateStore.balanceIndex = index
- }
- })
- // this.props.navigation.navigate('Backup_Account', { key: this.state.key })
- this.props.navigation.navigate('Tabbed_Navigation')
- } else {
- this.pair.setMeta({ name: this.state.name })
- this.json = this.pair.toJson(this.state.password)
- this.json.meta = this.pair.getMeta()
- SInfo.setItem(this.state.address, JSON.stringify(this.json), {
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- })
- this.props.rootStore.stateStore.isfirst = 1
- this.props.rootStore.stateStore.Accounts.push({
- account: this.state.name,
- address: this.pair.address()
- })
- this.props.rootStore.stateStore.Accountnum++
- this.props.rootStore.stateStore.Account = this.props.rootStore.stateStore.Accountnum
- this.props.rootStore.stateStore.balance = 0
- this.props.rootStore.stateStore.balances.push({
- address: this.state.address,
- balance: this.state.balance
- })
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (
- item.address ==
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- ) {
- this.props.rootStore.stateStore.balanceIndex = index
- }
- })
- if (this.state.way == 'Mnemonic' || this.state.way == 'Mnemonic24') {
- this.props.navigation.navigate('MnemonicWord_1', {
- key: this.state.key,
- address: this.state.address
- })
- } else {
- this.props.navigation.navigate('Backup_Account', {
- key: this.state.key,
- address: this.state.address
- })
- }
- }
- } else {
- Alert.alert('', i18n.t('Assets.ExistingAddress'))
- }
- })
- }
- }
- }
-
- render() {
- const pickerData = [
- { label: 'Assets.WordMnemonic12', value: 'Mnemonic' },
- { label: 'Assets.WordMnemonic24', value: 'Mnemonic24' },
- { label: 'Assets.RawSeed', value: 'Raw Seed' },
- { label: 'Assets.ImportKeystore', value: 'Keystore' }
- ]
- return (
-
-
-
-
- {this.props.rootStore.stateStore.isfirst != 0 ? (
- {
- ;(async () => {
- let balance = await polkadotAPI.freeBalance(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- )
- this.props.rootStore.stateStore.balance = String(balance)
- })()
- let resetAction = StackActions.reset({
- index: 0,
- actions: [
- NavigationActions.navigate({
- routeName: 'Tabbed_Navigation'
- })
- ]
- })
- this.props.navigation.dispatch(resetAction)
- }}
- style={{ paddingLeft: 20, height: 44, width: 61 }}
- activeOpacity={0.7}
- >
-
-
- ) : (
-
- )}
-
- {i18n.t('Assets.CreateAccount')}
-
-
-
-
-
- {/* 头像 | Identicon */}
-
-
-
- {/* 地址 | Address */}
-
-
- {this.state.address}
-
-
-
- {i18n.t('Assets.balance')}
- {formatBalance(this.state.balance)}
-
-
- {/* 虚线 | Dotted line */}
-
- {/* 密钥 | Key word */}
-
- {i18n.t('Assets.Createfrom')}
- {/* 选择方式 | Selection scheme */}
-
-
-
-
- {this.state.way != 'Keystore' && (
-
- {i18n.t('Assets.NameTheAccount')}
-
-
- )}
- {/* pass */}
-
- {i18n.t('Assets.Password')}
-
-
- {/* repeatPass 2 */}
-
- {i18n.t('Assets.EnterPassword_d')}
-
-
-
-
- {/* Reset or Save */}
-
-
-
-
- {i18n.t('TAB.Reset')}
-
-
-
-
- {i18n.t('TAB.Save')}
-
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- middle: {
- justifyContent: 'center',
- alignItems: 'center'
- },
- imageview: {
- justifyContent: 'center',
- alignItems: 'center',
- marginTop: ScreenHeight / 100,
- width: ScreenWidth,
- height: ScreenHeight / 10
- },
- image: {
- marginTop: ScreenHeight / 30,
- backgroundColor: 'white',
- borderRadius: ScreenHeight / 28,
- height: ScreenHeight / 14,
- width: ScreenHeight / 14,
- resizeMode: 'contain'
- },
- address_text: {
- marginTop: 21,
- width: ScreenWidth,
- alignItems: 'center',
- justifyContent: 'center'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- backgroundColor: '#776f71',
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- text1: {
- fontSize: 15,
- color: '#AAAAAA'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: 44,
- width: ScreenWidth * 0.8,
- borderWidth: 1,
- borderColor: '#d4cbcd',
- borderRadius: 4,
- paddingLeft: 13,
- marginTop: 12
- },
- NandP: {},
- Choose_way: {
- alignItems: 'center',
- marginLeft: ScreenWidth / 70,
- width: ScreenWidth * 0.25,
- height: ScreenHeight / 23,
- borderWidth: 1,
- borderRadius: ScreenHeight / 200,
- borderColor: 'red',
- flexDirection: 'row',
- backgroundColor: '#FF4081'
- },
- chooses: {
- paddingLeft: ScreenWidth / 20,
- paddingRight: ScreenWidth / 20,
- alignItems: 'center',
- justifyContent: 'space-between',
- flexDirection: 'row',
- height: ScreenHeight / 18,
- backgroundColor: '#DCDCDC'
- },
- choose_Text: {
- fontWeight: '500',
- fontSize: ScreenHeight / 50,
- color: '#4169E1'
- }
-})
-export default CreateAccount
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ TextInput,
+ Alert,
+ StatusBar,
+ SafeAreaView,
+ InteractionManager
+} from 'react-native'
+import Identicon from 'polkadot-identicon-react-native'
+import { formatBalance, hexToU8a, isHex, stringToU8a, u8aToHex } from '@polkadot/util'
+import { NavigationActions, StackActions } from 'react-navigation'
+import SInfo from 'react-native-sensitive-info'
+import Keyring from '@polkadot/keyring'
+import { randomAsU8a, mnemonicGenerate } from '@polkadot/util-crypto'
+
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, doubleClick } from '../../../util/Common'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+import RNPicker from '../../../components/RNPicker'
+
+const keyring = new Keyring()
+
+@inject('rootStore')
+@observer
+class CreateAccount extends Component {
+ constructor(props) {
+ super(props)
+ this.json
+ this.pair
+ this.state = {
+ way: 'Mnemonic',
+ way_change: 'Mnemonic',
+ isModel: false,
+ israndom: 1,
+ keyrandom: '',
+ key: '',
+ name: '',
+ password: '',
+ passwordErepeat: '',
+ address: 'xxxxxxxxxxxxxxxxxxxxxxxx',
+ islookpwd: false,
+ ispwd: 0,
+ ispwd2: 0,
+ balance: 0
+ }
+ this.Save_Account = this.Save_Account.bind(this)
+ this.onChangekey = this.onChangekey.bind(this)
+ this.onChangename = this.onChangename.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.Modify_way = this.Modify_way.bind(this)
+ this.Reset = this.Reset.bind(this)
+ this.onChangpasswordErepeat = this.onChangpasswordErepeat.bind(this)
+ }
+
+ /**
+ * @description 页面初始化加载|Page init load
+ */
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ ;(async () => {
+ let key = mnemonicGenerate()
+ this.pair = keyring.addFromMnemonic(key)
+ this.setState({
+ key: key,
+ address: this.pair.address()
+ })
+ const props = await polkadotAPI.properties()
+ formatBalance.setDefaults({
+ decimals: props.get('tokenDecimals'),
+ unit: props.get('tokenSymbol')
+ })
+ })()
+ })
+ }
+
+ /**
+ * @description 切换单位|Switching unit
+ * @param {String} way_change 单位|unit
+ */
+ Modify_way(way_change) {
+ this.setState({
+ isModel: false,
+ way: way_change,
+ way_change: way_change
+ })
+ let key
+ if (way_change == 'Keystore') {
+ this.setState({
+ key: '',
+ address: ''
+ })
+ return
+ } else if (way_change == 'Mnemonic') {
+ key = mnemonicGenerate()
+ } else if (way_change == 'Mnemonic24') {
+ key = mnemonicGenerate(24)
+ } else {
+ key = u8aToHex(randomAsU8a())
+ }
+ this.pair = keyring.addFromMnemonic(key)
+ this.setState({
+ key: key,
+ address: this.pair.address()
+ })
+ }
+
+ /**
+ * @description key 输入框发生改变|The key input box has changed
+ * @param {String} Changekey 改变的key值|The changed value of key
+ */
+ onChangekey(Changekey) {
+ let tag = true
+ let address = ''
+ if (this.state.way == 'Mnemonic' || this.state.way == 'Mnemonic24') {
+ try {
+ tag = true
+ this.pair = keyring.addFromMnemonic(Changekey)
+ address = this.pair.address()
+ this.setState({
+ key: Changekey,
+ address: this.pair.address()
+ })
+ } catch (e) {
+ tag = false
+ this.setState({
+ key: Changekey,
+ address: 'xxxxxxxxxxxxxxxxxxxxxxxx'
+ })
+ }
+ } else if (this.state.way == 'Raw Seed') {
+ try {
+ tag = true
+ if (isHex(Changekey) && Changekey.length === 66) {
+ let SEEDu8a = hexToU8a(Changekey)
+ this.pair = keyring.addFromSeed(SEEDu8a)
+ address = this.pair.address()
+ this.setState({
+ key: Changekey,
+ address: this.pair.address()
+ })
+ } else if (Changekey.length <= 32) {
+ let SEED = Changekey.padEnd(32, ' ')
+ let SEEDu8a = stringToU8a(SEED)
+ this.pair = keyring.addFromSeed(SEEDu8a)
+ address = this.pair.address()
+ this.setState({
+ key: Changekey,
+ address: this.pair.address()
+ })
+ } else {
+ tag = false
+ this.setState({
+ key: Changekey,
+ address: 'xxxxxxxxxxxxxxxxxxxxxxxx'
+ })
+ }
+ } catch (e) {
+ tag = false
+ this.setState({
+ key: Changekey,
+ address: 'xxxxxxxxxxxxxxxxxxxxxxxx'
+ })
+ }
+ } else {
+ try {
+ tag = true
+ address = JSON.parse(Changekey).address
+ this.setState({
+ key: Changekey,
+ address: JSON.parse(Changekey).address
+ })
+ } catch (e) {
+ this.setState({
+ key: Changekey,
+ address: 'xxxxxxxxxxxxxxxxxxxxxxxx'
+ })
+ tag = false
+ }
+ }
+ if (tag) {
+ ;(async () => {
+ let balance = await polkadotAPI.freeBalance(address)
+ this.setState({ balance: balance })
+ })()
+ }
+ }
+
+ /**
+ * @description 姓名更改|The name has been changed
+ * @param {String} Changename 更改的名称| The changed name
+ */
+ onChangename(Changename) {
+ this.setState({
+ name: Changename
+ })
+ }
+
+ /**
+ * @description 密码更改|The password has been changed
+ * @param {String} Changepassword 更改的密码|The changed password
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ if (Changepassword != '') {
+ this.setState({ ispwd: 1 })
+ }
+ if (Changepassword == '') {
+ this.setState({ ispwd: 0 })
+ }
+ }
+
+ /**
+ * @description 第二次重复密码更改|The repeat password has been changed
+ * @param {String} Changepassword 更改的密码|The changed password
+ */
+ onChangpasswordErepeat(Changepassword) {
+ this.setState({
+ passwordErepeat: Changepassword
+ })
+ if (Changepassword != this.state.password) {
+ this.setState({ ispwd2: 0 })
+ }
+ if (Changepassword == this.state.password) {
+ this.setState({ ispwd2: 1 })
+ }
+ }
+
+ /**
+ * @description 点击重置|Click Reset
+ */
+ Reset() {
+ let key
+ if (this.state.way == 'Keystore') {
+ this.setState({
+ key: '',
+ address: '',
+ balance: 0
+ })
+ return
+ } else if (this.state.way === 'Mnemonic') {
+ key = mnemonicGenerate()
+ } else if (this.state.way === 'Mnemonic24') {
+ key = mnemonicGenerate(24)
+ } else {
+ key = u8aToHex(randomAsU8a())
+ }
+ this.pair = keyring.addFromMnemonic(key)
+ this.setState({
+ key: key,
+ address: this.pair.address()
+ })
+ }
+
+ /**
+ * @description 点击保存|Click Save
+ */
+ Save_Account() {
+ if (this.state.name == '' && this.state.way != 'Keystore') {
+ return Alert.alert('', i18n.t('Assets.EnterName'))
+ }
+ if (this.state.password == '' || this.state.passwordErepeat == '') {
+ Alert.alert('', i18n.t('Assets.EnterPassword'))
+ } else {
+ if (this.state.password != this.state.passwordErepeat) {
+ Alert.alert('', i18n.t('Assets.CheckPassword'))
+ } else {
+ if (this.state.address == 'xxxxxxxxxxxxxxxxxxxxxxxx' || this.state.address == '') {
+ return Alert.alert('', i18n.t('TAB.enterInformation'))
+ }
+ // 开始校验密码
+ // Start checking password
+ SInfo.getItem(this.state.address, {
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ }).then(result => {
+ if (result == null) {
+ if (this.state.way == 'Keystore') {
+ // 导入key 校验密码
+ // Import key check password
+ let loadPair = keyring.addFromJson(JSON.parse(this.state.key))
+ try {
+ loadPair.decodePkcs8(this.state.password)
+ } catch (error) {
+ Alert.alert(
+ '',
+ i18n.t('TAB.PasswordMistake'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {}
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ loadPair.isLocked()
+ ? '' // 校验成功 | Checking success
+ : SInfo.setItem(this.state.address, this.state.key, {
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ })
+ this.props.rootStore.stateStore.isfirst = 1
+ this.props.rootStore.stateStore.Accounts.push({
+ account: JSON.parse(this.state.key).meta.name,
+ address: this.state.address
+ })
+ this.props.rootStore.stateStore.Accountnum++
+ this.props.rootStore.stateStore.Account = this.props.rootStore.stateStore.Accountnum
+ this.props.rootStore.stateStore.balances.push({
+ address: this.state.address,
+ balance: this.state.balance
+ })
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (
+ item.address ==
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ ) {
+ this.props.rootStore.stateStore.balanceIndex = index
+ }
+ })
+ // this.props.navigation.navigate('Backup_Account', { key: this.state.key })
+ this.props.navigation.navigate('Tabbed_Navigation')
+ } else {
+ this.pair.setMeta({ name: this.state.name })
+ this.json = this.pair.toJson(this.state.password)
+ this.json.meta = this.pair.getMeta()
+ SInfo.setItem(this.state.address, JSON.stringify(this.json), {
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ })
+ this.props.rootStore.stateStore.isfirst = 1
+ this.props.rootStore.stateStore.Accounts.push({
+ account: this.state.name,
+ address: this.pair.address()
+ })
+ this.props.rootStore.stateStore.Accountnum++
+ this.props.rootStore.stateStore.Account = this.props.rootStore.stateStore.Accountnum
+ this.props.rootStore.stateStore.balance = 0
+ this.props.rootStore.stateStore.balances.push({
+ address: this.state.address,
+ balance: this.state.balance
+ })
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (
+ item.address ==
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ ) {
+ this.props.rootStore.stateStore.balanceIndex = index
+ }
+ })
+ if (this.state.way == 'Mnemonic' || this.state.way == 'Mnemonic24') {
+ this.props.navigation.navigate('MnemonicWord_1', {
+ key: this.state.key,
+ address: this.state.address
+ })
+ } else {
+ this.props.navigation.navigate('Backup_Account', {
+ key: this.state.key,
+ address: this.state.address
+ })
+ }
+ }
+ } else {
+ Alert.alert('', i18n.t('Assets.ExistingAddress'))
+ }
+ })
+ }
+ }
+ }
+
+ render() {
+ const pickerData = [
+ { label: 'Assets.WordMnemonic12', value: 'Mnemonic' },
+ { label: 'Assets.WordMnemonic24', value: 'Mnemonic24' },
+ { label: 'Assets.RawSeed', value: 'Raw Seed' },
+ { label: 'Assets.ImportKeystore', value: 'Keystore' }
+ ]
+ return (
+
+
+
+
+ {this.props.rootStore.stateStore.isfirst != 0 ? (
+ {
+ ;(async () => {
+ let balance = await polkadotAPI.freeBalance(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ this.props.rootStore.stateStore.balance = String(balance)
+ })()
+ let resetAction = StackActions.reset({
+ index: 0,
+ actions: [
+ NavigationActions.navigate({
+ routeName: 'Tabbed_Navigation'
+ })
+ ]
+ })
+ this.props.navigation.dispatch(resetAction)
+ }}
+ style={{ paddingLeft: 20, height: 44, width: 61 }}
+ activeOpacity={0.7}
+ >
+
+
+ ) : (
+
+ )}
+
+ {i18n.t('Assets.CreateAccount')}
+
+
+
+
+
+ {/* 头像 | Identicon */}
+
+
+
+ {/* 地址 | Address */}
+
+
+ {this.state.address}
+
+
+
+ {i18n.t('Assets.balance')}
+ {formatBalance(this.state.balance)}
+
+
+ {/* 虚线 | Dotted line */}
+
+ {/* 密钥 | Key word */}
+
+ {i18n.t('Assets.Createfrom')}
+ {/* 选择方式 | Selection scheme */}
+
+
+
+
+ {this.state.way != 'Keystore' && (
+
+ {i18n.t('Assets.NameTheAccount')}
+
+
+ )}
+ {/* pass */}
+
+ {i18n.t('Assets.Password')}
+
+
+ {/* repeatPass 2 */}
+
+ {i18n.t('Assets.EnterPassword_d')}
+
+
+
+
+ {/* Reset or Save */}
+
+
+ {
+ doubleClick(this.Reset)
+ }}
+ >
+
+ {i18n.t('TAB.Reset')}
+
+
+ {
+ doubleClick(this.Save_Account)
+ }}
+ >
+
+ {i18n.t('TAB.Save')}
+
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ middle: {
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ imageview: {
+ justifyContent: 'center',
+ alignItems: 'center',
+ marginTop: ScreenHeight / 100,
+ width: ScreenWidth,
+ height: ScreenHeight / 10
+ },
+ image: {
+ marginTop: ScreenHeight / 30,
+ backgroundColor: 'white',
+ borderRadius: ScreenHeight / 28,
+ height: ScreenHeight / 14,
+ width: ScreenHeight / 14,
+ resizeMode: 'contain'
+ },
+ address_text: {
+ marginTop: 21,
+ width: ScreenWidth,
+ alignItems: 'center',
+ justifyContent: 'center'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ backgroundColor: '#776f71',
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ text1: {
+ fontSize: 15,
+ color: '#AAAAAA'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: 44,
+ width: ScreenWidth * 0.8,
+ borderWidth: 1,
+ borderColor: '#d4cbcd',
+ borderRadius: 4,
+ paddingLeft: 13,
+ marginTop: 12
+ },
+ NandP: {},
+ Choose_way: {
+ alignItems: 'center',
+ marginLeft: ScreenWidth / 70,
+ width: ScreenWidth * 0.25,
+ height: ScreenHeight / 23,
+ borderWidth: 1,
+ borderRadius: ScreenHeight / 200,
+ borderColor: 'red',
+ flexDirection: 'row',
+ backgroundColor: '#FF4081'
+ },
+ chooses: {
+ paddingLeft: ScreenWidth / 20,
+ paddingRight: ScreenWidth / 20,
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ flexDirection: 'row',
+ height: ScreenHeight / 18,
+ backgroundColor: '#DCDCDC'
+ },
+ choose_Text: {
+ fontWeight: '500',
+ fontSize: ScreenHeight / 50,
+ color: '#4169E1'
+ }
+})
+export default CreateAccount
diff --git a/src/page/Assets/secondary/MnemonicWord_1.js b/src/page/Assets/secondary/MnemonicWord_1.js
index eb58f8c3..3267ead4 100755
--- a/src/page/Assets/secondary/MnemonicWord_1.js
+++ b/src/page/Assets/secondary/MnemonicWord_1.js
@@ -1,218 +1,227 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { StyleSheet, Text, View, Image, TouchableOpacity, StatusBar, SafeAreaView, Modal } from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class MnemonicWord extends Component {
- constructor(props) {
- super(props)
- this.state = {
- TipTag: false
- }
- }
-
- // 显示禁止截屏提示
- // Display forbidden screen shot prompt
- showTip() {
- this.setState({
- TipTag: true
- })
- }
-
- // 下一步
- // The next step
- nextStep() {
- this.setState(
- {
- TipTag: false
- },
- () => {
- this.props.navigation.navigate('MnemonicWord_2', {
- key: this.props.navigation.state.params.key,
- address: this.props.navigation.state.params.address
- })
- }
- )
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
- {i18n.t('Assets.MWTitle')}
-
- {i18n.t('Assets.MWTip1')}
-
- {i18n.t('Assets.MWTip2')}
-
- {i18n.t('Assets.MWTip3')}
- {i18n.t('Assets.MWTip4')}
-
- {i18n.t('Assets.MWTip5')}
-
- {i18n.t('Assets.MWTip6')}
- {i18n.t('Assets.MWTip7')}
-
-
-
-
-
-
-
-
- {i18n.t('Assets.MWTip9')}
-
-
- {i18n.t('Assets.MWTip10')}
-
-
- {
- this.setState({
- TipTag: false
- })
- }}
- style={{
- flex: 1,
- borderRightWidth: 0.5,
- borderRightColor: '#ECE2E5',
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {i18n.t('Assets.MWTip11')}
-
-
- {i18n.t('Assets.MWTip12')}
-
-
-
-
-
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- }
-})
-export default MnemonicWord
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { StyleSheet, Text, View, Image, TouchableOpacity, StatusBar, SafeAreaView, Modal } from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, doubleClick } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class MnemonicWord extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ TipTag: false
+ }
+ }
+
+ /**
+ * @description 显示禁止截屏提示|Display forbidden screen shot prompt
+ */
+ showTip() {
+ this.setState({
+ TipTag: true
+ })
+ }
+
+ /**
+ * @description 下一步|The next step
+ */
+ nextStep() {
+ this.setState(
+ {
+ TipTag: false
+ },
+ () => {
+ this.props.navigation.navigate('MnemonicWord_2', {
+ key: this.props.navigation.state.params.key,
+ address: this.props.navigation.state.params.address
+ })
+ }
+ )
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+ {i18n.t('Assets.MWTitle')}
+
+ {i18n.t('Assets.MWTip1')}
+
+ {i18n.t('Assets.MWTip2')}
+
+ {i18n.t('Assets.MWTip3')}
+ {i18n.t('Assets.MWTip4')}
+
+ {i18n.t('Assets.MWTip5')}
+
+ {i18n.t('Assets.MWTip6')}
+ {i18n.t('Assets.MWTip7')}
+
+
+
+
+
+
+
+
+ {i18n.t('Assets.MWTip9')}
+
+
+ {i18n.t('Assets.MWTip10')}
+
+
+ {
+ this.setState({
+ TipTag: false
+ })
+ }}
+ activeOpacity={0.7}
+ style={{
+ flex: 1,
+ borderRightWidth: 0.5,
+ borderRightColor: '#ECE2E5',
+ alignItems: 'center',
+ justifyContent: 'center'
+ }}
+ >
+ {i18n.t('Assets.MWTip11')}
+
+ {
+ doubleClick(this.nextStep.bind(this))
+ }}
+ >
+ {i18n.t('Assets.MWTip12')}
+
+
+
+
+
+
+ {
+ doubleClick(this.showTip.bind(this))
+ }}
+ >
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ }
+})
+export default MnemonicWord
diff --git a/src/page/Assets/secondary/MnemonicWord_2.js b/src/page/Assets/secondary/MnemonicWord_2.js
index 7abc380c..1eb03a0e 100755
--- a/src/page/Assets/secondary/MnemonicWord_2.js
+++ b/src/page/Assets/secondary/MnemonicWord_2.js
@@ -1,143 +1,147 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { StyleSheet, Text, View, Image, TouchableOpacity, SafeAreaView, StatusBar } from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class MnemonicWord extends Component {
- // 下一步
- // The next step
- Next() {
- this.props.navigation.navigate('MnemonicWord_3', {
- key: this.props.navigation.state.params.key,
- address: this.props.navigation.state.params.address
- })
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
-
- {i18n.t('Assets.MWTip2')}
-
-
- {i18n.t('Assets.MWTip13')}
- {/* 虚线 | Dotted line */}
-
-
- {String(this.props.navigation.state.params.key)
- .split(' ')
- .map((v, i) => {
- return (
-
- {v}
-
- )
- })}
-
- {/* 虚线 | Dotted line */}
-
-
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- textView: {
- height: 30,
- borderColor: '#DDDDDD',
- borderWidth: 1,
- borderRadius: 2,
- marginTop: 14,
- marginRight: 12,
- paddingHorizontal: 12,
- justifyContent: 'center',
- alignItems: 'center'
- },
- text: {
- color: '#3E2D32',
- fontSize: 15
- }
-})
-export default MnemonicWord
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { StyleSheet, Text, View, Image, TouchableOpacity, SafeAreaView, StatusBar } from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, doubleClick } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class MnemonicWord extends Component {
+ /**
+ * @description 下一步|The next step
+ */
+ Next() {
+ this.props.navigation.navigate('MnemonicWord_3', {
+ key: this.props.navigation.state.params.key,
+ address: this.props.navigation.state.params.address
+ })
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+
+ {i18n.t('Assets.MWTip2')}
+
+
+ {i18n.t('Assets.MWTip13')}
+ {/* 虚线 | Dotted line */}
+
+
+ {String(this.props.navigation.state.params.key)
+ .split(' ')
+ .map((v, i) => {
+ return (
+
+ {v}
+
+ )
+ })}
+
+ {/* 虚线 | Dotted line */}
+
+
+
+ {
+ doubleClick(this.Next.bind(this))
+ }}
+ >
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ textView: {
+ height: 30,
+ borderColor: '#DDDDDD',
+ borderWidth: 1,
+ borderRadius: 2,
+ marginTop: 14,
+ marginRight: 12,
+ paddingHorizontal: 12,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ text: {
+ color: '#3E2D32',
+ fontSize: 15
+ }
+})
+export default MnemonicWord
diff --git a/src/page/Assets/secondary/MnemonicWord_3.js b/src/page/Assets/secondary/MnemonicWord_3.js
index 1182c996..8175d539 100755
--- a/src/page/Assets/secondary/MnemonicWord_3.js
+++ b/src/page/Assets/secondary/MnemonicWord_3.js
@@ -1,345 +1,391 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { StyleSheet, Text, View, TouchableOpacity, StatusBar, SafeAreaView, Alert } from 'react-native'
-import { NavigationActions, StackActions } from 'react-navigation'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-// 返回min和max之间的一个随机数,包括min和max
-// Returns a random number between min and Max, including min and Max
-function getRandomInt(min, max) {
- return Math.floor(Math.random() * (max - min + 1) + min) // +1是保证可以取到上限值
-}
-// 洗牌函数
-// Shuffle function
-function shuffle(arr) {
- let _arr = arr.slice()
- for (let i = 0; i < _arr.length; i++) {
- let j = getRandomInt(0, i)
- let t = _arr[i]
- _arr[i] = _arr[j]
- _arr[j] = t
- }
- return _arr
-}
-@inject('rootStore')
-@observer
-class MnemonicWord extends Component {
- constructor(props) {
- super(props)
- this.state = {
- selectWM: [], // 展示选择的WM | Show the selected WM
- WM: [], // 展示的WM | The WM to show
- oldWM: String(this.props.navigation.state.params.key).split(' '), // 预留判断的 | Reserved for judgment
- selectTag: false // 判断标识。false不匹配,true匹配 | Determine the identity. False does not match, true does
- }
- }
-
- // 提交
- // Submit
- Next() {
- if (this.state.selectWM.length == this.state.oldWM.length && this.state.selectTag) {
- // 创建查询每个账户的进程
- // Create a process to query each account
- ;(async () => {
- await polkadotAPI.freeBalance(this.state.address, balance => {
- let _address = this.state.address
- this.props.rootStore.stateStore.have = 0
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (item.address == _address) {
- this.props.rootStore.stateStore.have = 1
- this.props.rootStore.stateStore.balances[index].balance = balance
- }
- })
- if (this.props.rootStore.stateStore.have == 0) {
- this.props.rootStore.stateStore.balances.push({
- address: _address,
- balance: balance
- })
- }
- })
- })()
- let resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Tabbed_Navigation' })]
- })
- this.props.navigation.dispatch(resetAction)
- } else {
- Alert.alert('', i18n.t('Assets.MWTip15'))
- }
- }
-
- // 根据数组获取完整的str
- // Get the full str from the array
- getEndArr(arr) {
- let str = ''
- for (let i = 0; i < arr.length; i++) {
- str += arr[i].text
- }
- return str
- }
-
- // 校验选择的正确性
- // Verify the correctness of the selection
- checkArr() {
- this.setState({
- selectTag: this.getEndArr(this.state.selectWM) == this.state.oldWM.join('')
- })
- }
-
- // 添加上方展示的Word Mnemonic
- // Add Word Mnemonic shown above
- addWM(one) {
- this.changeWM(one)
- let selectWM = this.state.selectWM
- selectWM.push(one)
- this.setState(
- {
- selectWM
- },
- () => {
- if (this.state.selectWM.length == this.state.oldWM.length) {
- this.checkArr()
- } else {
- this.setState({
- selectTag: false
- })
- }
- }
- )
- }
-
- // 删除上方展示的Word Mnemonic
- // Remove Word Mnemonic shown above
- removeWM(one) {
- this.changeWM(one)
- let selectWM = this.state.selectWM
- for (let i = 0; i < selectWM.length; i++) {
- if (selectWM[i].text == one.text) {
- selectWM.splice(i, 1)
- }
- }
- this.setState({
- selectWM,
- selectTag: false
- })
- }
-
- // 改变下方展示的Word Mnemonic
- // Change the Word Mnemonic shown below
- changeWM(one) {
- let WM = this.state.WM
- for (let i = 0; i < WM.length; i++) {
- if (WM[i].text == one.text) {
- WM[i].tap = !WM[i].tap
- }
- }
- this.setState({
- WM
- })
- }
-
- setWM() {
- let WM = String(this.props.navigation.state.params.key).split(' ')
- WM = shuffle(WM)
- for (let i = 0; i < WM.length; i++) {
- WM[i] = {
- text: WM[i],
- tap: true
- }
- }
- this.setState({
- WM
- })
- }
-
- componentWillMount() {
- this.setWM()
- }
-
- componentDidMount() {
- // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
- // Start listening through addListener, didFocus RN lifecycle, page gets focus
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
- this.setWM()
- })
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- // Unlisten when the page disappears
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
-
- {i18n.t('Assets.MWTip2')}
-
-
- {i18n.t('Assets.MWTip14')}
- {!this.state.selectTag && this.state.selectWM.length == this.state.oldWM.length && (
-
- {i18n.t('Assets.MWTip15')}
-
- )}
- {/* 虚线 | Dotted line */}
- {this.state.selectWM.length > 0 && (
-
- )}
-
- {this.state.selectWM.map((v, i) => {
- return (
-
- {v.text}
-
- )
- })}
-
- {/* 虚线 | Dotted line */}
-
-
- {this.state.WM.map((v, i) => {
- return v.tap ? (
-
- {v.text}
-
- ) : (
-
- {v.text}
-
- )
- })}
-
- {/* 虚线 | Dotted line */}
-
-
-
-
- Complete
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- textView: {
- height: 30,
- borderColor: '#DDDDDD',
- borderWidth: 1,
- borderRadius: 2,
- marginTop: 14,
- marginRight: 12,
- paddingHorizontal: 12,
- justifyContent: 'center',
- alignItems: 'center'
- },
- text: {
- color: '#3E2D32',
- fontSize: 15
- }
-})
-export default MnemonicWord
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ TouchableOpacity,
+ StatusBar,
+ SafeAreaView,
+ Alert,
+ InteractionManager
+} from 'react-native'
+import { NavigationActions, StackActions } from 'react-navigation'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, doubleClick } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+/**
+ * @description 返回min和max之间的一个随机数,包括min和max|Returns a random number between min and Max, including min and Max
+ * @param {Num} min 最小值|The min value
+ * @param {Num} max 最大值|The max value
+ */
+function getRandomInt(min, max) {
+ return Math.floor(Math.random() * (max - min + 1) + min) // +1是保证可以取到上限值
+}
+/**
+ * @description 洗牌函数|Shuffle function
+ * @param {Array} arr 要重组的数组|Array to be reorganized
+ */
+function shuffle(arr) {
+ let _arr = arr.slice()
+ for (let i = 0; i < _arr.length; i++) {
+ let j = getRandomInt(0, i)
+ let t = _arr[i]
+ _arr[i] = _arr[j]
+ _arr[j] = t
+ }
+ return _arr
+}
+@inject('rootStore')
+@observer
+class MnemonicWord extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ selectWM: [], // 展示选择的WM | Show the selected WM
+ WM: [], // 展示的WM | The WM to show
+ oldWM: String(this.props.navigation.state.params.key).split(' '), // 预留判断的 | Reserved for judgment
+ selectTag: false // 判断标识。false不匹配,true匹配 | Determine the identity. False does not match, true does
+ }
+ }
+
+ /**
+ * @description 提交|Submit
+ */
+ Next() {
+ if (this.state.selectWM.length == this.state.oldWM.length && this.state.selectTag) {
+ // 创建查询每个账户的进程
+ // Create a process to query each account
+ ;(async () => {
+ await polkadotAPI.freeBalance(this.state.address, balance => {
+ let _address = this.state.address
+ this.props.rootStore.stateStore.have = 0
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (item.address == _address) {
+ this.props.rootStore.stateStore.have = 1
+ this.props.rootStore.stateStore.balances[index].balance = balance
+ }
+ })
+ if (this.props.rootStore.stateStore.have == 0) {
+ this.props.rootStore.stateStore.balances.push({
+ address: _address,
+ balance: balance
+ })
+ }
+ })
+ })()
+ let resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Tabbed_Navigation' })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ } else {
+ Alert.alert('', i18n.t('Assets.MWTip15'))
+ }
+ }
+
+ /**
+ * 根据数组获取完整的str|Get the full str from the array
+ * @param {Array} arr 要获取的数组|Array to get
+ */
+ getEndArr(arr) {
+ let str = ''
+ for (let i = 0; i < arr.length; i++) {
+ str += arr[i].text
+ }
+ return str
+ }
+
+ /**
+ * @description 校验选择的正确性|Verify the correctness of the selection
+ */
+ checkArr() {
+ this.setState({
+ selectTag: this.getEndArr(this.state.selectWM) == this.state.oldWM.join('')
+ })
+ }
+
+ /**
+ * @description 添加上方展示的Word Mnemonic|Add Word Mnemonic shown above
+ * @param {Object} one 添加项|Add item
+ */
+ addWM(one) {
+ this.changeWM(one)
+ let selectWM = this.state.selectWM
+ selectWM.push(one)
+ this.setState(
+ {
+ selectWM
+ },
+ () => {
+ if (this.state.selectWM.length == this.state.oldWM.length) {
+ this.checkArr()
+ } else {
+ this.setState({
+ selectTag: false
+ })
+ }
+ }
+ )
+ }
+
+ /**
+ * @description 删除上方展示的Word Mnemonic|Remove Word Mnemonic shown above
+ * @param {Object} one 删除项|Remove item
+ */
+ removeWM(one) {
+ this.changeWM(one)
+ let selectWM = this.state.selectWM
+ for (let i = 0; i < selectWM.length; i++) {
+ if (selectWM[i].text == one.text) {
+ selectWM.splice(i, 1)
+ }
+ }
+ this.setState({
+ selectWM,
+ selectTag: false
+ })
+ }
+
+ /**
+ * @description 改变下方展示的Word Mnemonic|Change the Word Mnemonic shown below
+ * @param {Object} one 改变项|Change item
+ */
+ changeWM(one) {
+ let WM = this.state.WM
+ for (let i = 0; i < WM.length; i++) {
+ if (WM[i].text == one.text) {
+ WM[i].tap = !WM[i].tap
+ }
+ }
+ this.setState({
+ WM
+ })
+ }
+
+ /**
+ * @description 选择空白的WM|Select the blank WM
+ */
+ setWM() {
+ let WM = String(this.props.navigation.state.params.key).split(' ')
+ WM = shuffle(WM)
+ for (let i = 0; i < WM.length; i++) {
+ WM[i] = {
+ text: WM[i],
+ tap: true
+ }
+ }
+ this.setState({
+ WM
+ })
+ }
+
+ componentWillMount() {
+ // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
+ // Start listening through addListener, didFocus RN lifecycle, page gets focus
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
+ this.setWM()
+ })
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ this.setWM()
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+
+ {i18n.t('Assets.MWTip2')}
+
+
+ {i18n.t('Assets.MWTip14')}
+ {!this.state.selectTag && this.state.selectWM.length == this.state.oldWM.length && (
+
+ {i18n.t('Assets.MWTip15')}
+
+ )}
+ {/* 虚线 | Dotted line */}
+ {this.state.selectWM.length > 0 && (
+
+ )}
+
+ {this.state.selectWM.map((v, i) => {
+ return (
+ {
+ doubleClick(this.removeWM.bind(this, v))
+ }}
+ >
+ {v.text}
+
+ )
+ })}
+
+ {/* 虚线 | Dotted line */}
+
+
+ {this.state.WM.map((v, i) => {
+ return v.tap ? (
+ {
+ doubleClick(this.addWM.bind(this, v))
+ }}
+ >
+ {v.text}
+
+ ) : (
+
+ {v.text}
+
+ )
+ })}
+
+ {/* 虚线 | Dotted line */}
+
+
+
+ {
+ doubleClick(this.Next.bind(this))
+ }}
+ >
+ Complete
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ textView: {
+ height: 30,
+ borderColor: '#DDDDDD',
+ borderWidth: 1,
+ borderRadius: 2,
+ marginTop: 14,
+ marginRight: 12,
+ paddingHorizontal: 12,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ text: {
+ color: '#3E2D32',
+ fontSize: 15
+ }
+})
+export default MnemonicWord
diff --git a/src/page/Assets/secondary/QRCode.js b/src/page/Assets/secondary/QRCode.js
index 7d2d88a3..ff157e6b 100755
--- a/src/page/Assets/secondary/QRCode.js
+++ b/src/page/Assets/secondary/QRCode.js
@@ -1,154 +1,165 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-20 21:01:02
- */
-import React, { Component } from 'react'
-import { View, Text, TouchableOpacity, Image, Clipboard, StatusBar, Platform, SafeAreaView, Alert } from 'react-native'
-import QRCode from 'react-native-qrcode'
-import Identicon from 'polkadot-identicon-react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, accountId } from '../../../util/Common'
-import Header from '../../../components/Header'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class QRCodeView extends Component {
- constructor(props) {
- super(props)
- this.state = {
- address: this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- }
- this.copy = this.copy.bind(this)
- this.back = this.back.bind(this)
- }
-
- async copy() {
- Clipboard.setString(this.state.address)
- Alert.alert('', i18n.t('TAB.CopySuccess'))
- }
-
- back() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- render() {
- return (
-
- {/* 标题栏 | The title bar */}
-
-
- {/* 导航栏 | The navigation bar */}
-
-
-
-
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].account}
-
-
-
-
-
-
-
- {this.state.address}
-
-
-
- {i18n.t('Assets.CopyAddress')}
-
-
-
-
-
-
- )
- }
-}
-export default QRCodeView
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { View, Text, TouchableOpacity, Image, Clipboard, StatusBar, Platform, SafeAreaView, Alert } from 'react-native'
+import QRCode from 'react-native-qrcode'
+import Identicon from 'polkadot-identicon-react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, accountId, doubleClick } from '../../../util/Common'
+import Header from '../../../components/Header'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class QRCodeView extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ address: this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ }
+ this.copy = this.copy.bind(this)
+ this.back = this.back.bind(this)
+ }
+
+ /**
+ * @description 复制|Click the copy
+ */
+ async copy() {
+ Clipboard.setString(this.state.address)
+ Alert.alert('', i18n.t('TAB.CopySuccess'))
+ }
+
+ /**
+ * @description 返回|Click the back
+ */
+ back() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ render() {
+ return (
+
+ {/* 标题栏 | The title bar */}
+
+
+ {/* 导航栏 | The navigation bar */}
+
+
+
+
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].account}
+
+
+
+
+
+
+
+ {this.state.address}
+
+ {
+ doubleClick(this.copy)
+ }}
+ activeOpacity={0.7}
+ >
+
+ {i18n.t('Assets.CopyAddress')}
+
+
+
+
+
+
+ )
+ }
+}
+export default QRCodeView
diff --git a/src/page/Assets/secondary/RightMenu.js b/src/page/Assets/secondary/RightMenu.js
index e15fe16d..fc15d505 100755
--- a/src/page/Assets/secondary/RightMenu.js
+++ b/src/page/Assets/secondary/RightMenu.js
@@ -1,213 +1,216 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { StyleSheet, Text, View, ScrollView, Image, TouchableOpacity, SafeAreaView } from 'react-native'
-import { observer, inject } from 'mobx-react'
-import Identicon from 'polkadot-identicon-react-native'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class RightMenu extends Component {
- constructor(props) {
- super(props)
- this.state = {
- Account: this.props.rootStore.stateStore.Account + 1
- }
- this.Create_Account = this.Create_Account.bind(this)
- this.Switch_Account = this.Switch_Account.bind(this)
- this.camera = this.camera.bind(this)
- }
-
- // 跳转 扫描界面
- // Jump to camera scan page
- camera() {
- this.props.t.setState({
- is: false
- })
- this.props.p.rootStore.stateStore.tocamera = 0
- this.props.p.navigation.navigate('Camera')
- }
-
- // 跳转 创建用户界面
- // Jump to Create_Account page
- Create_Account() {
- this.props.t.setState({
- is: false
- })
- this.props.p.navigation.navigate('Create_Account')
- }
-
- // 切换用户
- // Switch account
- Switch_Account() {
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (item.address == this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address) {
- this.props.rootStore.stateStore.balanceIndex = index
- }
- })
- }
-
- render() {
- return (
-
-
-
- {i18n.t('Assets.Menu')}
-
-
-
-
- {this.props.rootStore.stateStore.Accounts.map((item, index) => {
- if (index != 0) {
- return (
- {
- this.props.rootStore.stateStore.Account = index
- this.Switch_Account()
- }}
- activeOpacity={0.7}
- >
-
-
-
-
-
-
-
-
- {item.account}
-
-
- {item.address}
-
-
-
-
-
-
- )
- }
- })}
-
-
-
-
-
-
- {i18n.t('Assets.Scan')}
-
-
-
-
-
- {i18n.t('Assets.CreateAccount')}
-
-
-
-
-
- )
- }
-}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- // backgroundColor: '#ffffff00',
- flexDirection: 'row'
- },
- account: {
- height: ScreenHeight / 14,
- flexDirection: 'row',
- alignItems: 'center'
- },
- image: {
- height: ScreenHeight / 20,
- width: ScreenHeight / 20,
- resizeMode: 'contain',
- marginLeft: ScreenWidth / 35
- },
- line: {
- marginTop: ScreenHeight / 70,
- height: 1,
- backgroundColor: '#D3D3D3'
- },
- SandC: {
- flexDirection: 'row',
- marginTop: ScreenHeight / 70,
- height: ScreenHeight / 11.5,
- backgroundColor: 'white',
- alignItems: 'center'
- },
- middle: {
- justifyContent: 'center',
- alignItems: 'center'
- }
-})
-export default RightMenu
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { StyleSheet, Text, View, ScrollView, Image, TouchableOpacity, SafeAreaView } from 'react-native'
+import { observer, inject } from 'mobx-react'
+import Identicon from 'polkadot-identicon-react-native'
+import { ScreenWidth, ScreenHeight } from '../../../util/Common'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class RightMenu extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ Account: this.props.rootStore.stateStore.Account + 1
+ }
+ this.Create_Account = this.Create_Account.bind(this)
+ this.Switch_Account = this.Switch_Account.bind(this)
+ this.camera = this.camera.bind(this)
+ }
+
+ /**
+ * @description 跳转 扫描界面|Jump to camera scan page
+ */
+ camera() {
+ this.props.t.setState({
+ is: false
+ })
+ this.props.p.rootStore.stateStore.tocamera = 0
+ this.props.p.navigation.navigate('Camera')
+ }
+
+ /**
+ * @description 跳转 创建用户界面|Jump to Create_Account page
+ */
+ Create_Account() {
+ this.props.t.setState({
+ is: false
+ })
+ this.props.p.navigation.navigate('Create_Account')
+ }
+
+ /**
+ * @description 切换用户|Switch account
+ */
+ Switch_Account() {
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (item.address == this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address) {
+ this.props.rootStore.stateStore.balanceIndex = index
+ }
+ })
+ }
+
+ render() {
+ return (
+
+
+
+ {i18n.t('Assets.Menu')}
+
+
+
+
+ {this.props.rootStore.stateStore.Accounts.map((item, index) => {
+ if (index != 0) {
+ return (
+ {
+ this.props.rootStore.stateStore.Account = index
+ this.Switch_Account()
+ }}
+ activeOpacity={0.7}
+ >
+
+
+
+
+
+
+
+
+ {item.account}
+
+
+ {item.address}
+
+
+
+
+
+
+ )
+ }
+ })}
+
+
+
+
+
+
+ {i18n.t('Assets.Scan')}
+
+
+
+
+
+ {i18n.t('Assets.CreateAccount')}
+
+
+
+
+
+ )
+ }
+}
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ // backgroundColor: '#ffffff00',
+ flexDirection: 'row'
+ },
+ account: {
+ height: ScreenHeight / 14,
+ flexDirection: 'row',
+ alignItems: 'center'
+ },
+ image: {
+ height: ScreenHeight / 20,
+ width: ScreenHeight / 20,
+ resizeMode: 'contain',
+ marginLeft: ScreenWidth / 35
+ },
+ line: {
+ marginTop: ScreenHeight / 70,
+ height: 1,
+ backgroundColor: '#D3D3D3'
+ },
+ SandC: {
+ flexDirection: 'row',
+ marginTop: ScreenHeight / 70,
+ height: ScreenHeight / 11.5,
+ backgroundColor: 'white',
+ alignItems: 'center'
+ },
+ middle: {
+ justifyContent: 'center',
+ alignItems: 'center'
+ }
+})
+export default RightMenu
diff --git a/src/page/Assets/secondary/Transfer/MakeTransfer.js b/src/page/Assets/secondary/Transfer/MakeTransfer.js
index b35fbdeb..a707de73 100755
--- a/src/page/Assets/secondary/Transfer/MakeTransfer.js
+++ b/src/page/Assets/secondary/Transfer/MakeTransfer.js
@@ -1,482 +1,504 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-19 23:03:08
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- Modal,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, checkPwd, formatData } from '../../../../util/Common'
-import Header from '../../../../components/Header'
-import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../../util/polkadotAPI'
-import i18n from '../../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Transfer extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- password: '',
- isModal: false,
- accountNonce: '',
- onlyone: 0,
- type: 'pending...'
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepasswore = this.onChangepasswore.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
- }
-
- // 密码展示
- // Display password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // 密码更改
- // Change password
- onChangepasswore(Changepasswore) {
- this.setState({
- password: Changepasswore
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.rootStore.stateStore.t_address = ''
- this.props.navigation.navigate('Transfer')
- }
-
- getAccountNonce() {
- ;(async () => {
- const accountNonce = await polkadotAPI.accountNonce(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- )
- this.setState({
- accountNonce: JSON.stringify(accountNonce)
- })
- })()
- }
-
- // 页面初始化
- // Page initialization
- componentWillMount() {
- this.getAccountNonce()
- }
-
- componentDidMount() {
- // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
- // Start listening through addListener, didFocus RN lifecycle, page gets focus
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', () => {
- this.getAccountNonce()
- })
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- // Unlisten when the page disappears
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- // 点击提交
- // Click Submit
- Sign_and_Submit() {
- this.setState({
- onlyone: 1,
- isModal: true
- })
- const _this = this
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- // 检测api长时间(15s)没有返回,或者报错监听不到
- // The detection API did not return for a long time (15s), or the error report could not be monitored
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.rootStore.stateStore.t_address = ''
- _this.props.navigation.navigate('Transfer')
- _this.setState({
- isModal: false
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- const accountNonce = await polkadotAPI.accountNonce(loadPair.address())
- // Do the transfer and track the actual status
- let transfer
- try {
- transfer = await polkadotAPI.transfer(
- _this.props.rootStore.stateStore.inaddress,
- _this.props.rootStore.stateStore.value
- )
- } catch (e) {
- Alert.alert(
- '',
- i18n.t('TAB.TransferFailed'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.rootStore.stateStore.t_address = ''
- _this.props.navigation.navigate('Transfer')
- _this.setState({
- isModal: false
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
-
- // 签名 发送
- // Signature to send
- transfer.sign(loadPair, accountNonce).send(({ status }) => {
- status = formatData(status)
- if (status.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success'
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Assets.TransferSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Coin_details')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | The title bar */}
-
-
-
-
-
-
- {i18n.t('Assets.SubmitTransaction')}
-
- {i18n.t('TAB.signMess')}
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
-
-
- {i18n.t('Assets.calling')}
-
- balances.transfer
-
- {i18n.t('Assets.withIndex')}
-
- {this.state.accountNonce}
-
-
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Reset or Save */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
-
- {i18n.t('Assets.SignAndSubmit')}
-
-
- ) : (
-
-
- {i18n.t('Assets.SignAndSubmit')}
-
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- submit_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 2,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- }
-})
-export default Transfer
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ Modal,
+ Alert,
+ StatusBar,
+ SafeAreaView,
+ InteractionManager
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, checkPwd, formatData, doubleClick } from '../../../../util/Common'
+import Header from '../../../../components/Header'
+import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../../util/polkadotAPI'
+import i18n from '../../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Transfer extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ password: '',
+ isModal: false,
+ accountNonce: '',
+ onlyone: 0,
+ type: 'pending...'
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepasswore = this.onChangepasswore.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
+ }
+
+ /**
+ * @description 密码展示 | Display password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 密码更改 | Change password
+ * @param {String} Changepasswore
+ */
+ onChangepasswore(Changepasswore) {
+ this.setState({
+ password: Changepasswore
+ })
+ }
+
+ /**
+ * @description 点击取消 | Click Cancel
+ */
+ Cancel() {
+ this.props.rootStore.stateStore.t_address = ''
+ this.props.navigation.navigate('Transfer')
+ }
+
+ /**
+ * @description 获取账户的Nonce
+ */
+ getAccountNonce() {
+ ;(async () => {
+ const accountNonce = await polkadotAPI.accountNonce(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ this.setState({
+ accountNonce: JSON.stringify(accountNonce)
+ })
+ })()
+ }
+
+ /**
+ * @description 页面初始化 | Page initialization
+ */
+ componentWillMount() {
+ InteractionManager.runAfterInteractions(() => {
+ this.getAccountNonce()
+ })
+ }
+
+ componentDidMount() {
+ // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
+ // Start listening through addListener, didFocus RN lifecycle, page gets focus
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', () => {
+ InteractionManager.runAfterInteractions(() => {
+ this.getAccountNonce()
+ })
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ /**
+ * @description 点击提交 | Click Submit
+ */
+ Sign_and_Submit() {
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const _this = this
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ // 检测api长时间(15s)没有返回,或者报错监听不到
+ // The detection API did not return for a long time (15s), or the error report could not be monitored
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.rootStore.stateStore.t_address = ''
+ _this.props.navigation.navigate('Transfer')
+ _this.setState({
+ isModal: false
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ const accountNonce = await polkadotAPI.accountNonce(loadPair.address())
+ // Do the transfer and track the actual status
+ let transfer
+ try {
+ transfer = await polkadotAPI.transfer(
+ _this.props.rootStore.stateStore.inaddress,
+ _this.props.rootStore.stateStore.value
+ )
+ } catch (e) {
+ Alert.alert(
+ '',
+ i18n.t('TAB.TransferFailed'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.rootStore.stateStore.t_address = ''
+ _this.props.navigation.navigate('Transfer')
+ _this.setState({
+ isModal: false
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+
+ // 签名 发送
+ // Signature to send
+ transfer.sign(loadPair, accountNonce).send(({ status }) => {
+ status = formatData(status)
+ if (status.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success'
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Assets.TransferSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Coin_details')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | The title bar */}
+
+
+
+
+
+
+ {i18n.t('Assets.SubmitTransaction')}
+
+ {i18n.t('TAB.signMess')}
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+
+
+ {i18n.t('Assets.calling')}
+
+ balances.transfer
+
+ {i18n.t('Assets.withIndex')}
+
+ {this.state.accountNonce}
+
+
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Reset or Save */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+ {
+ doubleClick(this.Sign_and_Submit)
+ }}
+ >
+
+ {i18n.t('Assets.SignAndSubmit')}
+
+
+ ) : (
+
+
+ {i18n.t('Assets.SignAndSubmit')}
+
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ submit_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 2,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ }
+})
+export default Transfer
diff --git a/src/page/Assets/secondary/Transfer/Transfer.js b/src/page/Assets/secondary/Transfer/Transfer.js
index b67d84e3..a2582774 100755
--- a/src/page/Assets/secondary/Transfer/Transfer.js
+++ b/src/page/Assets/secondary/Transfer/Transfer.js
@@ -1,405 +1,429 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-20 20:42:10
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- StatusBar,
- SafeAreaView,
- Alert
-} from 'react-native'
-import { formatBalance } from '@polkadot/util'
-import { observer, inject } from 'mobx-react'
-import { getUnit, ScreenWidth, ScreenHeight } from '../../../../util/Common'
-import Header from '../../../../components/Header'
-import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../../util/polkadotAPI'
-import i18n from '../../../../locales/i18n'
-import RNPicker from '../../../../components/RNPicker'
-
-@inject('rootStore')
-@observer
-class Transfer extends Component {
- constructor(props) {
- super(props)
- this.state = {
- balance: 0,
- address: '',
- value: 0,
- isModel: false,
- way: 'DOT',
- way_change: 'DOT',
- multiple: 1000000000000000,
- fees: {},
- tfColor: '#CCC'
- }
- this.Make_transfer = this.Make_transfer.bind(this)
- this.back = this.back.bind(this)
- this.ChangeAddress = this.ChangeAddress.bind(this)
- this.ChangeValue = this.ChangeValue.bind(this)
- this.addresses = this.addresses.bind(this)
- this.camera = this.camera.bind(this)
- this.Modify_way = this.Modify_way.bind(this)
- }
-
- // 点击返回
- // Click back
- back() {
- this.props.rootStore.stateStore.t_address = ''
- this.props.rootStore.stateStore.isaddresses = 0
- this.props.rootStore.stateStore.transfer_address = 0
- this.props.rootStore.stateStore.iscamera = 0
- if (this.props.rootStore.stateStore.tocamera == 0) {
- this.props.navigation.navigate('Tabbed_Navigation')
- } else {
- this.props.navigation.navigate('Coin_details')
- }
- }
-
- // 更改单位
- // Switch units
- Modify_way(way_change) {
- this.setState({
- isModel: false,
- way_change: way_change,
- way: way_change,
- multiple: getUnit(way_change),
- tfColor: this.state.balance > this.state.value * this.state.multiple ? '#CCC' : 'red'
- })
- }
-
- // 点击扫一扫
- // Click Scan
- camera() {
- this.props.rootStore.stateStore.tocamera = 1
- this.props.navigation.navigate('Camera')
- }
-
- // 选择通讯录
- // Switch Addresses
- addresses() {
- this.props.rootStore.stateStore.transfer_address = 1
- this.props.navigation.navigate('Addresses')
- }
-
- // 点击转账
- // Click Transfer
- Make_transfer() {
- if (this.state.address == '') {
- Alert.alert('', i18n.t('Assets.PleaseEnterAddress'))
- } else if (this.state.value == '') {
- Alert.alert('', i18n.t('Assets.enterValue'))
- } else if (this.state.balance < this.state.value * this.state.multiple) {
- Alert.alert('', i18n.t('Assets.enterInformation'))
- } else {
- this.props.rootStore.stateStore.value = String(this.state.value * this.state.multiple)
- this.props.rootStore.stateStore.inaddress =
- this.props.rootStore.stateStore.isaddresses == 0 && this.props.rootStore.stateStore.iscamera == 0
- ? this.state.address
- : this.props.rootStore.stateStore.t_address
- this.props.rootStore.stateStore.isaddresses = 0
- this.props.rootStore.stateStore.transfer_address = 0
- this.props.rootStore.stateStore.iscamera = 0
- this.props.navigation.navigate('Make_transfer')
- }
- }
-
- // 输入转账地址 改变
- // Change the transfer address
- ChangeAddress(changeAddress) {
- if (changeAddress != '') {
- this.props.rootStore.stateStore.isaddresses = 0
- } else {
- if (this.props.rootStore.stateStore.transfer_address == 1) {
- this.props.rootStore.stateStore.isaddresses = 1
- }
- }
- this.setState({
- address: changeAddress
- })
- }
-
- ChangeValue(changeValue) {
- this.setState({
- value: changeValue,
- tfColor: this.state.balance > changeValue * this.state.multiple ? '#CCC' : 'red'
- })
- }
-
- // 页面初始化
- // Page initialization
- componentWillMount() {
- ;(async () => {
- this.props.rootStore.stateStore.tocamera = 1
- polkadotAPI.freeBalance(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address,
- balance => {
- this.setState({
- balance: balance
- })
- }
- )
- this.setState({ fees: await polkadotAPI.fees() })
- })()
- }
-
- componentDidMount() {
- // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
- // Start listening through addListener, didFocus RN lifecycle page gets focus
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
- if (String(this.props.rootStore.stateStore.t_address)) {
- this.ChangeAddress(String(this.props.rootStore.stateStore.t_address))
- }
- })
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- // Unlisten when the page disappears
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
- {i18n.t('Assets.recipientAddress')}
-
- {
- this.ChangeAddress(changeText)
- }}
- />
-
-
-
-
-
- {i18n.t('Assets.sendOf')}
-
- {i18n.t('Assets.Balance')}:{formatBalance(String(this.state.balance))}
-
-
-
- {
- this.ChangeValue(changeText)
- }}
- />
-
-
-
-
-
-
- {i18n.t('Assets.creationFee') + ':'}+{formatBalance(String(this.state.fees.creationFee || 0))}
-
-
-
-
- {i18n.t('Assets.existentialDeposit') + ':'}
- {formatBalance(String(this.state.fees.existentialDeposit || 0))}
-
-
-
-
- {i18n.t('Assets.transactionBaseFee') + ':'}
- {formatBalance(String(this.state.fees.transactionBaseFee || 0))}
-
-
-
-
- {i18n.t('Assets.transactionByteFee') + ':'}
- {formatBalance(String(this.state.fees.transactionByteFee || 0))}
-
-
-
-
- {i18n.t('Assets.transferFee') + ':'}
- {formatBalance(String(this.state.fees.transferFee || 0))}
-
-
-
-
-
-
- {i18n.t('Assets.MakeTransfer')}
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {},
- NandP: {
- justifyContent: 'center',
- paddingLeft: ScreenWidth / 20,
- height: ScreenHeight / 7
- },
- textInputStyle: {
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: 'grey',
- borderRadius: 5,
- paddingLeft: ScreenHeight / 100,
- paddingVertical: 0
- },
- image: {
- height: 30,
- width: 30,
- resizeMode: 'contain',
- tintColor: '#ccc'
- },
- maket: {
- height: 44,
- width: ScreenWidth - 40,
- marginLeft: 20,
- borderRadius: 6,
- backgroundColor: '#F14B79',
- justifyContent: 'center',
- alignItems: 'center',
- marginBottom: 43
- },
- Choose_way: {
- alignItems: 'center',
- marginLeft: ScreenWidth / 70,
- width: ScreenWidth * 0.25,
- height: ScreenHeight / 23,
- borderWidth: 1,
- borderRadius: ScreenHeight / 200,
- borderColor: '#4dabd0',
- flexDirection: 'row',
- backgroundColor: '#4dabd0'
- },
- middle: {
- justifyContent: 'center',
- alignItems: 'center'
- },
- chooses: {
- paddingLeft: ScreenWidth / 20,
- paddingRight: ScreenWidth / 20,
- alignItems: 'center',
- justifyContent: 'space-between',
- flexDirection: 'row',
- height: ScreenHeight / 18,
- backgroundColor: '#DCDCDC'
- },
- choose_Text: {
- fontWeight: '500',
- fontSize: ScreenHeight / 50,
- color: '#4169E1'
- },
- feesView: {
- color: '#888888',
- fontSize: 14,
- marginBottom: 12
- },
- feesText: {
- color: '#696969',
- fontSize: ScreenHeight / 60
- }
-})
-export default Transfer
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ StatusBar,
+ SafeAreaView,
+ Alert,
+ InteractionManager
+} from 'react-native'
+import { formatBalance } from '@polkadot/util'
+import { observer, inject } from 'mobx-react'
+import { getUnit, ScreenWidth, ScreenHeight, doubleClick } from '../../../../util/Common'
+import Header from '../../../../components/Header'
+import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../../util/polkadotAPI'
+import i18n from '../../../../locales/i18n'
+import RNPicker from '../../../../components/RNPicker'
+
+@inject('rootStore')
+@observer
+class Transfer extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ balance: 0,
+ address: '',
+ value: 0,
+ isModel: false,
+ way: 'DOT',
+ way_change: 'DOT',
+ multiple: 1000000000000000,
+ fees: {},
+ tfColor: '#CCC'
+ }
+ this.Make_transfer = this.Make_transfer.bind(this)
+ this.back = this.back.bind(this)
+ this.ChangeAddress = this.ChangeAddress.bind(this)
+ this.ChangeValue = this.ChangeValue.bind(this)
+ this.addresses = this.addresses.bind(this)
+ this.camera = this.camera.bind(this)
+ this.Modify_way = this.Modify_way.bind(this)
+ }
+
+ /**
+ * @description 点击返回 | Click back
+ */
+ back() {
+ this.props.rootStore.stateStore.t_address = ''
+ this.props.rootStore.stateStore.isaddresses = 0
+ this.props.rootStore.stateStore.transfer_address = 0
+ this.props.rootStore.stateStore.iscamera = 0
+ if (this.props.rootStore.stateStore.tocamera == 0) {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ } else {
+ this.props.navigation.navigate('Coin_details')
+ }
+ }
+
+ /**
+ * @description 更改单位 | Switch units
+ * @param {String} way_change
+ */
+ Modify_way(way_change) {
+ this.setState({
+ isModel: false,
+ way_change: way_change,
+ way: way_change,
+ multiple: getUnit(way_change),
+ tfColor: this.state.balance > this.state.value * this.state.multiple ? '#CCC' : 'red'
+ })
+ }
+
+ /**
+ * @description 点击扫一扫|Click Scan
+ */
+ camera() {
+ this.props.rootStore.stateStore.tocamera = 1
+ this.props.navigation.navigate('Camera')
+ }
+
+ /**
+ * @description 选择通讯录|Switch Addresses
+ */
+ addresses() {
+ this.props.rootStore.stateStore.transfer_address = 1
+ this.props.navigation.navigate('Addresses')
+ }
+
+ /**
+ * @description 点击转账|Click Transfer
+ */
+ Make_transfer() {
+ if (this.state.address == '') {
+ Alert.alert('', i18n.t('Assets.PleaseEnterAddress'))
+ } else if (this.state.value == '') {
+ Alert.alert('', i18n.t('Assets.enterValue'))
+ } else if (this.state.balance < this.state.value * this.state.multiple) {
+ Alert.alert('', i18n.t('Assets.enterInformation'))
+ } else {
+ this.props.rootStore.stateStore.value = String(this.state.value * this.state.multiple)
+ this.props.rootStore.stateStore.inaddress =
+ this.props.rootStore.stateStore.isaddresses == 0 && this.props.rootStore.stateStore.iscamera == 0
+ ? this.state.address
+ : this.props.rootStore.stateStore.t_address
+ this.props.rootStore.stateStore.isaddresses = 0
+ this.props.rootStore.stateStore.transfer_address = 0
+ this.props.rootStore.stateStore.iscamera = 0
+ this.props.navigation.navigate('Make_transfer')
+ }
+ }
+
+ /**
+ * @description 输入转账地址改变|Change of transfer address
+ * @param {String} changeAddress
+ */
+ ChangeAddress(changeAddress) {
+ if (changeAddress != '') {
+ this.props.rootStore.stateStore.isaddresses = 0
+ } else {
+ if (this.props.rootStore.stateStore.transfer_address == 1) {
+ this.props.rootStore.stateStore.isaddresses = 1
+ }
+ }
+ this.setState({
+ address: changeAddress
+ })
+ }
+
+ /**
+ * @description 转账金额的更改 | Change of transfer balance
+ * @param {String} changeValue
+ */
+ ChangeValue(changeValue) {
+ this.setState({
+ value: changeValue,
+ tfColor: this.state.balance > changeValue * this.state.multiple ? '#CCC' : 'red'
+ })
+ }
+
+ /**
+ * @description 页面初始化|Page initialization
+ */
+ componentWillMount() {
+ InteractionManager.runAfterInteractions(() => {
+ ;(async () => {
+ this.props.rootStore.stateStore.tocamera = 1
+ polkadotAPI.freeBalance(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address,
+ balance => {
+ this.setState({
+ balance: balance
+ })
+ }
+ )
+ this.setState({ fees: await polkadotAPI.fees() })
+ })()
+ })
+ }
+
+ componentDidMount() {
+ // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
+ // Start listening through addListener, didFocus RN lifecycle page gets focus
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
+ InteractionManager.runAfterInteractions(() => {
+ if (String(this.props.rootStore.stateStore.t_address)) {
+ this.ChangeAddress(String(this.props.rootStore.stateStore.t_address))
+ }
+ })
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+ {i18n.t('Assets.recipientAddress')}
+
+ {
+ this.ChangeAddress(changeText)
+ }}
+ />
+
+
+
+
+
+ {i18n.t('Assets.sendOf')}
+
+ {i18n.t('Assets.Balance')}:{formatBalance(String(this.state.balance))}
+
+
+
+ {
+ this.ChangeValue(changeText)
+ }}
+ />
+
+
+
+
+
+
+ {i18n.t('Assets.creationFee') + ':'}+{formatBalance(String(this.state.fees.creationFee || 0))}
+
+
+
+
+ {i18n.t('Assets.existentialDeposit') + ':'}
+ {formatBalance(String(this.state.fees.existentialDeposit || 0))}
+
+
+
+
+ {i18n.t('Assets.transactionBaseFee') + ':'}
+ {formatBalance(String(this.state.fees.transactionBaseFee || 0))}
+
+
+
+
+ {i18n.t('Assets.transactionByteFee') + ':'}
+ {formatBalance(String(this.state.fees.transactionByteFee || 0))}
+
+
+
+
+ {i18n.t('Assets.transferFee') + ':'}
+ {formatBalance(String(this.state.fees.transferFee || 0))}
+
+
+
+
+
+ {
+ doubleClick(this.Make_transfer)
+ }}
+ activeOpacity={0.7}
+ >
+ {i18n.t('Assets.MakeTransfer')}
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {},
+ NandP: {
+ justifyContent: 'center',
+ paddingLeft: ScreenWidth / 20,
+ height: ScreenHeight / 7
+ },
+ textInputStyle: {
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: 'grey',
+ borderRadius: 5,
+ paddingLeft: ScreenHeight / 100,
+ paddingVertical: 0
+ },
+ image: {
+ height: 30,
+ width: 30,
+ resizeMode: 'contain',
+ tintColor: '#ccc'
+ },
+ maket: {
+ height: 44,
+ width: ScreenWidth - 40,
+ marginLeft: 20,
+ borderRadius: 6,
+ backgroundColor: '#F14B79',
+ justifyContent: 'center',
+ alignItems: 'center',
+ marginBottom: 43
+ },
+ Choose_way: {
+ alignItems: 'center',
+ marginLeft: ScreenWidth / 70,
+ width: ScreenWidth * 0.25,
+ height: ScreenHeight / 23,
+ borderWidth: 1,
+ borderRadius: ScreenHeight / 200,
+ borderColor: '#4dabd0',
+ flexDirection: 'row',
+ backgroundColor: '#4dabd0'
+ },
+ middle: {
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ chooses: {
+ paddingLeft: ScreenWidth / 20,
+ paddingRight: ScreenWidth / 20,
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ flexDirection: 'row',
+ height: ScreenHeight / 18,
+ backgroundColor: '#DCDCDC'
+ },
+ choose_Text: {
+ fontWeight: '500',
+ fontSize: ScreenHeight / 50,
+ color: '#4169E1'
+ },
+ feesView: {
+ color: '#888888',
+ fontSize: 14,
+ marginBottom: 12
+ },
+ feesText: {
+ color: '#696969',
+ fontSize: ScreenHeight / 60
+ }
+})
+export default Transfer
diff --git a/src/page/Assets/secondary/Transfer/TransferDetails.js b/src/page/Assets/secondary/Transfer/TransferDetails.js
index fa78ccf7..42416c18 100755
--- a/src/page/Assets/secondary/Transfer/TransferDetails.js
+++ b/src/page/Assets/secondary/Transfer/TransferDetails.js
@@ -1,301 +1,310 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-22 09:42:30
- */
-import React, { PureComponent } from 'react'
-import {
- View,
- Text,
- StyleSheet,
- Image,
- TouchableOpacity,
- TouchableWithoutFeedback,
- Clipboard,
- StatusBar,
- SafeAreaView,
- Alert,
- Linking
-} from 'react-native'
-import moment from 'moment/moment'
-import { formatBalance } from '@polkadot/util'
-import { observer, inject } from 'mobx-react'
-import QRCode from 'react-native-qrcode'
-import { ScreenWidth, ScreenHeight } from '../../../../util/Common'
-import Header from '../../../../components/Header'
-import i18n from '../../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Transfer_details extends PureComponent {
- constructor(props) {
- super(props)
- this.state = {
- data: this.props.navigation.state.params.data,
- url: 'https://polkascan.io/pre/alexander/system/block/'
- }
- this.back = this.back.bind(this)
- this.copyTo = this.copyTo.bind(this)
- this.copyFrom = this.copyFrom.bind(this)
- }
-
- // 点击返回
- back() {
- this.props.navigation.navigate('Coin_details')
- }
-
- // 拷贝
- async copyTo() {
- Clipboard.setString(
- this.state.data.tx_type == 'Send'
- ? this.state.data.tx_address
- : this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- )
- Alert.alert('', i18n.t('TAB.CopySuccess'))
- }
-
- // 拷贝 form
- async copyFrom() {
- Clipboard.setString(
- this.state.data.tx_type == 'Send'
- ? this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- : this.state.data.tx_address
- )
- Alert.alert('', i18n.t('TAB.CopySuccess'))
- }
-
- // 打开区块浏览器
- open = () => {
- Linking.openURL(this.state.url + String(this.state.data.tx_blocknumber))
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
- {/* 图标 */}
-
- {/* 状态 */}
-
- {this.state.data.tx_type + ':' + i18n.t('Assets.Successed')}
-
- {/* 日期 */}
-
- {moment(this.state.data.tx_timestamp).format('DD/MM/YYYY HH:mm:ss')}
-
-
-
- {/* Balance */}
-
- {i18n.t('Assets.Balance')}:
- {formatBalance(String(this.state.data.tx_value))}
-
- {/* Fees */}
-
- {i18n.t('Assets.Fees')}:
- {formatBalance(String(this.state.data.tx_fees))}
-
- {/* To */}
-
-
- {i18n.t('Assets.To')}:
-
-
-
- {this.state.data.tx_type == 'Send'
- ? this.state.data.tx_address
- : this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
-
- {
- this.copyTo()
- }}
- >
-
-
-
- {/* From */}
-
-
- {i18n.t('Assets.From')}:
-
-
-
- {this.state.data.tx_type == 'Send'
- ? this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- : this.state.data.tx_address}
-
-
-
- {
- this.copyFrom()
- }}
- >
-
-
-
- {/* Block */}
-
- {i18n.t('Assets.Block')}:
- #{this.state.data.tx_blocknumber}
-
- {/* BlockHash */}
-
- {i18n.t('Assets.BlockHash')}:
-
- {this.state.data.tx_blockhash}
-
-
-
-
- View in the Polkascan.io
-
-
-
-
-
-
-
-
-
- )
- }
-}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- list_View: {
- marginTop: ScreenHeight / 50,
- height: ScreenHeight / 20,
- flexDirection: 'row',
- alignItems: 'center'
- },
- list_text1: {
- width: ScreenWidth * 0.25,
- fontSize: 16,
- color: '#AAAAAA'
- },
- list_text2: {
- flex: 1,
- fontSize: 14,
- color: '#3E2D32'
- },
- list_image: {
- marginLeft: ScreenWidth * 0.05,
- marginRight: ScreenWidth * 0.02,
- height: ScreenHeight / 40,
- width: ScreenHeight / 40,
- resizeMode: 'contain'
- },
- grey_text: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center'
- },
- address: {
- fontSize: 14,
- color: '#3E2D32',
- margin: ScreenHeight / 200
- },
- viewForText: {
- marginTop: ScreenHeight / 50,
- fontSize: 16,
- justifyContent: 'center',
- alignItems: 'center',
- color: '#3E2D32',
- marginBottom: 20
- }
-})
-export default Transfer_details
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { PureComponent } from 'react'
+import {
+ View,
+ Text,
+ StyleSheet,
+ Image,
+ TouchableOpacity,
+ TouchableWithoutFeedback,
+ Clipboard,
+ StatusBar,
+ SafeAreaView,
+ Alert,
+ Linking
+} from 'react-native'
+import moment from 'moment/moment'
+import { formatBalance } from '@polkadot/util'
+import { observer, inject } from 'mobx-react'
+import QRCode from 'react-native-qrcode'
+import { ScreenWidth, ScreenHeight } from '../../../../util/Common'
+import Header from '../../../../components/Header'
+import i18n from '../../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Transfer_details extends PureComponent {
+ constructor(props) {
+ super(props)
+ this.state = {
+ data: this.props.navigation.state.params.data,
+ url: 'https://polkascan.io/pre/alexander/system/block/'
+ }
+ this.back = this.back.bind(this)
+ this.copyTo = this.copyTo.bind(this)
+ this.copyFrom = this.copyFrom.bind(this)
+ }
+
+ /**
+ * @description 点击返回 | Click the back
+ */
+ back() {
+ this.props.navigation.navigate('Coin_details')
+ }
+
+ /**
+ * @description 拷贝 | Click the copy of "To address"
+ */
+ async copyTo() {
+ Clipboard.setString(
+ this.state.data.tx_type == 'Send'
+ ? this.state.data.tx_address
+ : this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ Alert.alert('', i18n.t('TAB.CopySuccess'))
+ }
+
+ /**
+ * @description 拷贝 from | Click the copy of "From address"
+ */
+ async copyFrom() {
+ Clipboard.setString(
+ this.state.data.tx_type == 'Send'
+ ? this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ : this.state.data.tx_address
+ )
+ Alert.alert('', i18n.t('TAB.CopySuccess'))
+ }
+
+ /**
+ * @description 打开区块浏览器 | Open the block explorer
+ */
+ open = () => {
+ Linking.openURL(this.state.url + String(this.state.data.tx_blocknumber))
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+ {/* 图标 */}
+
+ {/* 状态 */}
+
+ {this.state.data.tx_type + ':' + i18n.t('Assets.Successed')}
+
+ {/* 日期 */}
+
+ {moment(this.state.data.tx_timestamp).format('DD/MM/YYYY HH:mm:ss')}
+
+
+
+ {/* Balance */}
+
+ {i18n.t('Assets.Balance')}:
+ {formatBalance(String(this.state.data.tx_value))}
+
+ {/* Fees */}
+
+ {i18n.t('Assets.Fees')}:
+ {formatBalance(String(this.state.data.tx_fees))}
+
+ {/* To */}
+
+
+ {i18n.t('Assets.To')}:
+
+
+
+ {this.state.data.tx_type == 'Send'
+ ? this.state.data.tx_address
+ : this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+
+ {
+ this.copyTo()
+ }}
+ activeOpacity={0.7}
+ >
+
+
+
+ {/* From */}
+
+
+ {i18n.t('Assets.From')}:
+
+
+
+ {this.state.data.tx_type == 'Send'
+ ? this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ : this.state.data.tx_address}
+
+
+
+ {
+ this.copyFrom()
+ }}
+ activeOpacity={0.7}
+ >
+
+
+
+ {/* Block */}
+
+ {i18n.t('Assets.Block')}:
+ #{this.state.data.tx_blocknumber}
+
+ {/* BlockHash */}
+
+ {i18n.t('Assets.BlockHash')}:
+
+ {this.state.data.tx_blockhash}
+
+
+
+
+ View in the Polkascan.io
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ list_View: {
+ marginTop: ScreenHeight / 50,
+ height: ScreenHeight / 20,
+ flexDirection: 'row',
+ alignItems: 'center'
+ },
+ list_text1: {
+ width: ScreenWidth * 0.25,
+ fontSize: 16,
+ color: '#AAAAAA'
+ },
+ list_text2: {
+ flex: 1,
+ fontSize: 14,
+ color: '#3E2D32'
+ },
+ list_image: {
+ marginLeft: ScreenWidth * 0.05,
+ marginRight: ScreenWidth * 0.02,
+ height: ScreenHeight / 40,
+ width: ScreenHeight / 40,
+ resizeMode: 'contain'
+ },
+ grey_text: {
+ flex: 1,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ address: {
+ fontSize: 14,
+ color: '#3E2D32',
+ margin: ScreenHeight / 200
+ },
+ viewForText: {
+ fontSize: 16,
+ justifyContent: 'center',
+ alignItems: 'center',
+ color: '#3E2D32',
+ paddingVertical: 20
+ }
+})
+export default Transfer_details
diff --git a/src/page/Democracy/Democracy.js b/src/page/Democracy/Democracy.js
index 9f9b5a38..c2524cf9 100755
--- a/src/page/Democracy/Democracy.js
+++ b/src/page/Democracy/Democracy.js
@@ -1,183 +1,199 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-19 21:24:18
- */
-import React, { Component } from 'react'
-import { Text, View, TouchableOpacity, ScrollView, SafeAreaView, StatusBar, Platform } from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth } from '../../util/Common'
-import Referendums from './Referendums'
-import Proposals from './Proposals'
-import polkadotAPI from '../../util/polkadotAPI'
-import i18n from '../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Democracy extends Component {
- constructor(props) {
- super(props)
- this.state = {
- activeTap: 1,
- publicPropCount: '0',
- referendumCount: '0',
- referendumActive: 0,
- referendums: [],
- proposalsNum: 0
- }
- }
-
- componentDidMount() {
- // 通过addListener开启监听,可以使用上面的四个属性
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
- this.setState({})
- if (Platform.OS == 'android') {
- StatusBar.setBackgroundColor('#FFF')
- }
- StatusBar.setBarStyle('dark-content')
- })
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- componentWillMount() {
- this.loadPage()
- }
-
- loadPage() {
- ;(async () => {
- if (Platform.OS == 'android') {
- StatusBar.setBackgroundColor('#FFF')
- }
- StatusBar.setBarStyle('dark-content')
- // 查询publicPropCount
- await polkadotAPI.publicPropCount(result => {
- this.setState({
- publicPropCount: JSON.stringify(result)
- })
- })
- // 查询referendumCount
- await polkadotAPI.referendumCount(result => {
- this.props.rootStore.stateStore.referendumCount = JSON.stringify(result)
- })
- await polkadotAPI.publicProps(result => {
- this.setState({ proposalsNum: result.length })
- })
- // 查询referendums中referendumActive
- await polkadotAPI.referendums(result => {
- this.setState({
- referendumActive: result.length
- })
- })
- })()
- }
-
- render() {
- return (
-
-
-
- {
- this.setState({
- activeTap: 1
- })
- }}
- style={{
- flex: 1,
- flexDirection: 'row',
- justifyContent: 'center',
- alignItems: 'center'
- }}
- >
-
- {i18n.t('Democracy.referendums')}
- {'(' + this.props.rootStore.stateStore.referendumCount + ')'}
-
-
- {'+' + this.state.referendumActive}
-
-
- {
- this.setState({
- activeTap: 2
- })
- }}
- style={{
- flex: 1,
- flexDirection: 'row',
- justifyContent: 'center',
- alignItems: 'center'
- }}
- >
-
- {i18n.t('Democracy.proposals')}
- {'(' + this.state.publicPropCount + ')'}
-
-
- {'+' + this.state.proposalsNum}
-
-
-
- {this.state.activeTap == 1 ? (
-
- ) : (
-
-
-
- )}
-
- )
- }
-}
-export default Democracy
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ Text,
+ View,
+ TouchableOpacity,
+ ScrollView,
+ SafeAreaView,
+ StatusBar,
+ Platform,
+ InteractionManager
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth } from '../../util/Common'
+import Referendums from './Referendums'
+import Proposals from './Proposals'
+import polkadotAPI from '../../util/polkadotAPI'
+import i18n from '../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Democracy extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ activeTap: 1,
+ publicPropCount: '0',
+ referendumCount: '0',
+ referendumActive: 0,
+ referendums: [],
+ proposalsNum: 0
+ }
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ this.loadPage()
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ componentWillMount() {
+ // 通过addListener开启监听,可以使用上面的四个属性
+ // With addListener to enable listening, can use the four properties above
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
+ this.setState({})
+ if (Platform.OS == 'android') {
+ StatusBar.setBackgroundColor('#FFF')
+ }
+ StatusBar.setBarStyle('dark-content')
+ })
+ }
+
+ /**
+ * @description 页面初始化 加载相应的数据|The page initializes and loads the corresponding data
+ */
+ loadPage() {
+ ;(async () => {
+ if (Platform.OS == 'android') {
+ StatusBar.setBackgroundColor('#FFF')
+ }
+ StatusBar.setBarStyle('dark-content')
+ // Query publicPropCount
+ await polkadotAPI.publicPropCount(result => {
+ this.setState({
+ publicPropCount: JSON.stringify(result)
+ })
+ })
+ // Query referendumCount
+ await polkadotAPI.referendumCount(result => {
+ this.props.rootStore.stateStore.referendumCount = JSON.stringify(result)
+ })
+ await polkadotAPI.publicProps(result => {
+ this.setState({ proposalsNum: result.length })
+ })
+ // Query referendumActive of referendums
+ await polkadotAPI.referendums(result => {
+ this.setState({
+ referendumActive: result.length
+ })
+ })
+ })()
+ }
+
+ render() {
+ return (
+
+
+
+ {
+ this.setState({
+ activeTap: 1
+ })
+ }}
+ style={{
+ flex: 1,
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center'
+ }}
+ >
+
+ {i18n.t('Democracy.referendums')}
+ {'(' + this.props.rootStore.stateStore.referendumCount + ')'}
+
+
+ {this.state.referendumActive != 0 && '+' + this.state.referendumActive}
+
+
+ {
+ this.setState({
+ activeTap: 2
+ })
+ }}
+ style={{
+ flex: 1,
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center'
+ }}
+ >
+
+ {i18n.t('Democracy.proposals')}
+ {'(' + this.state.publicPropCount + ')'}
+
+
+ {this.state.proposalsNum != 0 && '+' + this.state.proposalsNum}
+
+
+
+ {this.state.activeTap == 1 ? (
+
+ ) : (
+
+
+
+ )}
+
+ )
+ }
+}
+export default Democracy
diff --git a/src/page/Democracy/Proposals.js b/src/page/Democracy/Proposals.js
index d76facee..0f4adbb8 100755
--- a/src/page/Democracy/Proposals.js
+++ b/src/page/Democracy/Proposals.js
@@ -1,140 +1,164 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Text, View } from 'react-native'
-import { Method } from '@polkadot/types'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../util/Common'
-import ProposalsRow from '../../components/ProposalsRow'
-import polkadotAPI from '../../util/polkadotAPI'
-import i18n from '../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Proposals extends Component {
- constructor(props) {
- super(props)
- this.state = {
- publicProps: [],
- Actives_Nofixed: [],
- Actives_Nofixedvalue: [],
- Actives_Title: [],
- votingCountdown: 0,
- launchCountdown: 0,
- Index: [],
- votingState: [],
- balances: []
- }
- this.balances = this.balances.bind(this)
- }
-
- balances() {
- ;(async () => {
- let launchPeriod = await polkadotAPI.launchPeriod()
- await polkadotAPI.bestNumber(bestNumber => {
- this.setState({ launchCountdown: launchPeriod - bestNumber.mod(launchPeriod).addn(1) })
- })
- await polkadotAPI.publicProps(result => {
- this.setState({
- publicProps: [],
- Actives_Nofixed: [],
- Actives_Nofixedvalue: [],
- Actives_Title: [],
- Index: [],
- balances: []
- })
- result.map((item, index) => {
- if (item) {
- let { meta, method, section } = Method.findFunction(item[1].callIndex)
- this.state.Actives_Title.push({ section: section, method: method })
- this.state.Actives_Nofixedvalue.push(item[1].args)
- this.state.Actives_Nofixed.push(meta.args)
- this.state.publicProps.push(item)
- this.state.Index.push(item[0])
- }
- this.setState({})
- })
- })
- for (let i = 0; i < this.state.Index.length; i++) {
- let balance = await polkadotAPI.depositOf(this.state.Index[i])
- if (balance) {
- this.state.balances.push(JSON.parse(balance)[0])
- }
- this.setState({})
- }
- for (let i = 0; i < this.state.balances.length; i++) {
- for (let j = 0; j < this.state.balances.length - i - 1; j++) {
- if (this.state.balances[j] < this.state.balances[j + 1]) {
- let tmp = this.state.balances[j]
- this.state.balances[j] = this.state.balances[j + 1]
- this.state.balances[j + 1] = tmp
- let tmp_publicProps = this.state.publicProps[j]
- this.state.publicProps[j] = this.state.publicProps[j + 1]
- this.state.publicProps[j + 1] = tmp_publicProps
- let tmp_Actives_Nofixed = this.state.Actives_Nofixed[j]
- this.state.Actives_Nofixed[j] = this.state.Actives_Nofixed[j + 1]
- this.state.Actives_Nofixed[j + 1] = tmp_Actives_Nofixed
- let tmp_Actives_Nofixedvalue = this.state.Actives_Nofixedvalue[j]
- this.state.Actives_Nofixedvalue[j] = this.state.Actives_Nofixedvalue[j + 1]
- this.state.Actives_Nofixedvalue[j + 1] = tmp_Actives_Nofixedvalue
- this.setState({})
- }
- this.setState({})
- }
- this.setState({})
- }
- })()
- }
-
- componentWillMount() {
- ;(async () => {
- let launchPeriod = await polkadotAPI.launchPeriod()
-
- await polkadotAPI.bestNumber(bestNumber => {
- this.setState({ launchCountdown: launchPeriod - bestNumber.mod(launchPeriod).addn(1) })
- })
- await polkadotAPI.publicProps(result => {
- this.balances()
- })
- })()
- }
-
- render() {
- return (
-
- {this.state.publicProps[0] == null ? (
-
- {i18n.t('Democracy.noProposals')}
-
- ) : (
-
- )}
-
- )
- }
-}
-export default Proposals
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Text, View } from 'react-native'
+import { Method } from '@polkadot/types'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight } from '../../util/Common'
+import ProposalsRow from '../../components/ProposalsRow'
+import polkadotAPI from '../../util/polkadotAPI'
+import i18n from '../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Proposals extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ publicProps: [],
+ Actives_Nofixed: [],
+ Actives_Nofixedvalue: [],
+ Actives_Title: [],
+ votingCountdown: 0,
+ launchCountdown: 0,
+ Index: [],
+ votingState: [],
+ balances: []
+ }
+ this.getProposals = this.getProposals.bind(this)
+ }
+
+ /**
+ * @description 获取提案相关信息|Get information about the proposal
+ */
+ getProposals() {
+ ;(async () => {
+ let launchPeriod = await polkadotAPI.launchPeriod()
+ await polkadotAPI.bestNumber(bestNumber => {
+ this.setState({
+ launchCountdown: launchPeriod - bestNumber.mod(launchPeriod).addn(1)
+ })
+ })
+ await polkadotAPI.publicProps(result => {
+ this.setState(
+ {
+ publicProps: [],
+ Actives_Nofixed: [],
+ Actives_Nofixedvalue: [],
+ Actives_Title: [],
+ Index: [],
+ balances: []
+ },
+ () => {
+ ;(async () => {
+ result.map((item, index) => {
+ if (item) {
+ let info = item[1]
+ try {
+ if (item[1].proposal.args.proposal) {
+ info = item[1].proposal.args
+ }
+ } catch (e) {}
+ let { meta, method, section } = Method.findFunction(info.callIndex)
+ this.state.Actives_Title.push({
+ section: section,
+ method: method
+ })
+ this.state.Actives_Nofixedvalue.push(info.args)
+ this.state.Actives_Nofixed.push(meta.args)
+ this.state.publicProps.push(item)
+ this.state.Index.push(item[0])
+ }
+ this.setState({})
+ })
+ for (let i = 0; i < this.state.Index.length; i++) {
+ let balance = await polkadotAPI.depositOf(this.state.Index[i])
+ if (balance) {
+ this.state.balances.push(balance)
+ }
+ this.setState({})
+ }
+ for (let i = 0; i < this.state.balances.length; i++) {
+ for (let j = 0; j < this.state.balances.length - i - 1; j++) {
+ if (this.state.balances[j] < this.state.balances[j + 1]) {
+ let tmp = this.state.balances[j]
+ this.state.balances[j] = this.state.balances[j + 1]
+ this.state.balances[j + 1] = tmp
+ let tmp_publicProps = this.state.publicProps[j]
+ this.state.publicProps[j] = this.state.publicProps[j + 1]
+ this.state.publicProps[j + 1] = tmp_publicProps
+ let tmp_Actives_Nofixed = this.state.Actives_Nofixed[j]
+ this.state.Actives_Nofixed[j] = this.state.Actives_Nofixed[j + 1]
+ this.state.Actives_Nofixed[j + 1] = tmp_Actives_Nofixed
+ let tmp_Actives_Nofixedvalue = this.state.Actives_Nofixedvalue[j]
+ this.state.Actives_Nofixedvalue[j] = this.state.Actives_Nofixedvalue[j + 1]
+ this.state.Actives_Nofixedvalue[j + 1] = tmp_Actives_Nofixedvalue
+ this.setState({})
+ }
+ this.setState({})
+ }
+ this.setState({})
+ }
+ })()
+ }
+ )
+ })
+ })()
+ }
+
+ componentDidMount() {
+ // InteractionManager.runAfterInteractions(() => {
+ ;(async () => {
+ let launchPeriod = await polkadotAPI.launchPeriod()
+
+ await polkadotAPI.bestNumber(bestNumber => {
+ this.setState({
+ launchCountdown: launchPeriod - bestNumber.mod(launchPeriod).addn(1)
+ })
+ })
+ await polkadotAPI.publicProps(result => {
+ this.getProposals()
+ })
+ })()
+ // })
+ }
+
+ render() {
+ return (
+
+ {this.state.publicProps[0] == null ? (
+
+ {i18n.t('Democracy.noProposals')}
+
+ ) : (
+
+ )}
+
+ )
+ }
+}
+export default Proposals
diff --git a/src/page/Democracy/Referendums.js b/src/page/Democracy/Referendums.js
index 6ee4108a..d747cbcb 100755
--- a/src/page/Democracy/Referendums.js
+++ b/src/page/Democracy/Referendums.js
@@ -1,71 +1,75 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Text, View, TouchableOpacity } from 'react-native'
-import { observer, inject } from 'mobx-react'
-import Active from '../../components/Active'
-import History from './secondary/History'
-import { ScreenWidth } from '../../util/Common'
-import i18n from '../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Referendums extends Component {
- constructor(props) {
- super(props)
- this.state = {
- activeTap: 1
- }
- }
-
- render() {
- return (
-
-
- {
- this.setState({
- activeTap: 1
- })
- }}
- >
-
-
- {i18n.t('Democracy.Active')}
-
-
-
-
- {this.state.activeTap == 1 ? : }
-
- )
- }
-}
-export default Referendums
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Text, View, TouchableOpacity } from 'react-native'
+import { observer, inject } from 'mobx-react'
+import Active from '../../components/Active'
+import { ScreenWidth } from '../../util/Common'
+import i18n from '../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Referendums extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ activeTap: 1
+ }
+ }
+
+ render() {
+ return (
+
+
+ {
+ this.setState({
+ activeTap: 1
+ })
+ }}
+ activeOpacity={0.7}
+ >
+
+
+ {i18n.t('Democracy.Active')}
+
+
+
+
+ {this.state.activeTap == 1 ? (
+
+ ) : (
+
+ )}
+
+ )
+ }
+}
+export default Referendums
diff --git a/src/page/Democracy/secondary/History.js b/src/page/Democracy/secondary/History.js
old mode 100755
new mode 100644
index 2319f3cf..c31eebf5
--- a/src/page/Democracy/secondary/History.js
+++ b/src/page/Democracy/secondary/History.js
@@ -1,357 +1,347 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Text, View, Image, TouchableOpacity } from 'react-native'
-import { VictoryPie } from 'victory-native'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-
-const Actives_fixed = [
- {
- name: 'councilVoting.setCooloffPeriod',
- time: '310',
- number: 49,
- Aye: 5042964,
- aye: 368,
- Nay: 2512889,
- nay: 58,
- result: 'Pass',
- Actives_Nofixed: [{ name: 'blocks:Compact', num: 256 }]
- },
- {
- name: 'councilVoting.setCooloffPeriod',
- time: '310',
- number: 48,
- Aye: 5042964,
- aye: 368,
- Nay: 2512889,
- nay: 58,
- result: 'NoPass',
- Actives_Nofixed: [{ name: 'Compact', num: 252 }]
- },
- {
- name: 'councilVoting.setCooloffPeriod',
- time: '310',
- number: 47,
- Aye: 5042964,
- aye: 368,
- Nay: 2512889,
- nay: 58,
- result: 'Pass',
- Actives_Nofixed: [
- { name: 'who:Address', num: '5rgjhfdkjgbfdkjvbcvbkdjvbdfghjsdffd' },
- { name: 'free:Compact', num: 18000 },
- { name: 'reserved:Compact', num: 180000 }
- ]
- }
-]
-export default class History extends Component {
- constructor(props) {
- super(props)
- }
-
- render() {
- return (
-
- {Actives_fixed.map((item, index) => (
-
-
-
- {item.name}
-
-
-
- {item.time}
-
-
- {' '}
- {' blocks end'}
-
-
-
- #{item.number}
-
-
- {item.Actives_Nofixed.map((itemNo, indexNo) => (
-
- {itemNo.name}
-
-
- {itemNo.num}
-
-
-
- ))}
-
- Threshold: Super majority approval
-
-
- The result of voting:
-
-
-
- {item.result}
-
-
-
-
-
-
- {`Aye ${item.Aye}`}
-
-
- 66.75%
-
- {`(${item.aye})`}
-
-
- {`Nay ${item.Nay}`}
-
-
- 33.25%
-
- {`(${item.nay})`}
-
-
-
- {/* Nay or Aye */}
-
-
-
-
- Nay
-
-
-
-
- Aye
-
-
-
- or
-
-
-
-
-
- ))}
-
- )
- }
-}
+import React, { Component } from 'react'
+import { Text, View, Image, TouchableOpacity } from 'react-native'
+import { VictoryPie } from 'victory-native'
+import { ScreenWidth, ScreenHeight } from '../../../util/Common'
+
+const Actives_fixed = [
+ {
+ name: 'councilVoting.setCooloffPeriod',
+ time: '310',
+ number: 49,
+ Aye: 5042964,
+ aye: 368,
+ Nay: 2512889,
+ nay: 58,
+ result: 'Pass',
+ Actives_Nofixed: [{ name: 'blocks:Compact', num: 256 }]
+ },
+ {
+ name: 'councilVoting.setCooloffPeriod',
+ time: '310',
+ number: 48,
+ Aye: 5042964,
+ aye: 368,
+ Nay: 2512889,
+ nay: 58,
+ result: 'NoPass',
+ Actives_Nofixed: [{ name: 'Compact', num: 252 }]
+ },
+ {
+ name: 'councilVoting.setCooloffPeriod',
+ time: '310',
+ number: 47,
+ Aye: 5042964,
+ aye: 368,
+ Nay: 2512889,
+ nay: 58,
+ result: 'Pass',
+ Actives_Nofixed: [
+ { name: 'who:Address', num: '5rgjhfdkjgbfdkjvbcvbkdjvbdfghjsdffd' },
+ { name: 'free:Compact', num: 18000 },
+ { name: 'reserved:Compact', num: 180000 }
+ ]
+ }
+]
+export default class History extends Component {
+ constructor(props) {
+ super(props)
+ }
+
+ render() {
+ return (
+
+ {Actives_fixed.map((item, index) => (
+
+
+
+ {item.name}
+
+
+
+ {item.time}
+
+
+ {' '}
+ {' blocks end'}
+
+
+
+ #{item.number}
+
+
+ {item.Actives_Nofixed.map((itemNo, indexNo) => (
+
+ {itemNo.name}
+
+
+ {itemNo.num}
+
+
+
+ ))}
+
+ Threshold: Super majority approval
+
+
+ The result of voting:
+
+
+
+ {item.result}
+
+
+
+
+
+
+ {`Aye ${item.Aye}`}
+
+
+ 66.75%
+
+ {`(${item.aye})`}
+
+
+ {`Nay ${item.Nay}`}
+
+
+ 33.25%
+
+ {`(${item.nay})`}
+
+
+
+ {/* Nay or Aye */}
+
+
+
+
+ Nay
+
+
+
+
+ Aye
+
+
+
+ or
+
+
+
+
+
+ ))}
+
+ )
+ }
+}
diff --git a/src/page/Democracy/secondary/NayorAye.js b/src/page/Democracy/secondary/Vote.js
old mode 100755
new mode 100644
similarity index 89%
rename from src/page/Democracy/secondary/NayorAye.js
rename to src/page/Democracy/secondary/Vote.js
index 2bb5c580..306d1125
--- a/src/page/Democracy/secondary/NayorAye.js
+++ b/src/page/Democracy/secondary/Vote.js
@@ -1,370 +1,388 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- Modal,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, checkPwd, formatData } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class NayorAye extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- password: '',
- isModal: false,
- onlyone: 0,
- type: 'pending...',
- index: this.props.navigation.state.params.index,
- choose: this.props.navigation.state.params.choose
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Vote = this.Vote.bind(this)
- }
-
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- Vote() {
- this.setState({
- onlyone: 1,
- isModal: true
- })
- const _this = this
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- let transfer
- try {
- transfer = await polkadotAPI.vote(Number(_this.state.index), _this.state.choose == 'Aye' ? true : false)
- } catch (e) {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- Alert.alert('', i18n.t('Democracy.VoteFailed'))
- }
- transfer.signAndSend(loadPair, ({ status }) => {
- status = formatData(status)
- if (status.Finalized) {
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Democracy.VoteSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- type: 'success'
- })
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
- {/* index */}
- democrary.vote
-
- {i18n.t('Democracy.referendumIndex')}:
-
-
- {/* choose */}
- {i18n.t('Democracy.vote')}:
-
- {/* password */}
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Cancel or nominate */}
-
-
- Cancel
-
-
- Vote
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: '#FFF'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- nominate_view: {
- backgroundColor: '#fff',
- marginTop: 40,
- alignSelf: 'center',
- width: ScreenWidth,
- borderRadius: ScreenHeight / 100,
- paddingHorizontal: 20
- },
- title_b: {
- color: '#3E2D32',
- fontSize: 18,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100,
- borderTopRightRadius: 0,
- borderBottomRightRadius: 0
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- },
- choessText: {
- fontWeight: '500',
- fontSize: ScreenWidth / 28,
- color: 'white'
- }
-})
-export default NayorAye
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ Modal,
+ Alert,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, checkPwd, formatData, doubleClick } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Vote extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ password: '',
+ isModal: false,
+ onlyone: 0,
+ type: 'pending...',
+ index: this.props.navigation.state.params.index,
+ choose: this.props.navigation.state.params.choose
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Vote = this.Vote.bind(this)
+ }
+
+ /**
+ * @description 切换密码的可见性|Toggle password visibility
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 密码更改|Password change
+ * @param {String} Changepassword 更改的密码|Changed password
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description 点击取消|Click the cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 点击Vote|Click the vote
+ */
+ Vote() {
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const _this = this
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ let transfer
+ try {
+ transfer = await polkadotAPI.vote(Number(_this.state.index), _this.state.choose == 'Aye' ? true : false)
+ } catch (e) {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ Alert.alert('', i18n.t('Democracy.VoteFailed'))
+ }
+ transfer.signAndSend(loadPair, ({ status }) => {
+ status = formatData(status)
+ if (status.Finalized) {
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Democracy.VoteSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ type: 'success'
+ })
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+ {/* index */}
+ democrary.vote
+
+ {i18n.t('Democracy.referendumIndex')}:
+
+
+ {/* choose */}
+ {i18n.t('Democracy.vote')}:
+
+ {/* password */}
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Cancel or nominate */}
+
+
+ Cancel
+
+ {
+ doubleClick(this.Vote)
+ }}
+ >
+ Vote
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: '#FFF'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ nominate_view: {
+ backgroundColor: '#fff',
+ marginTop: 40,
+ alignSelf: 'center',
+ width: ScreenWidth,
+ borderRadius: ScreenHeight / 100,
+ paddingHorizontal: 20
+ },
+ title_b: {
+ color: '#3E2D32',
+ fontSize: 18,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100,
+ borderTopRightRadius: 0,
+ borderBottomRightRadius: 0
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ },
+ choessText: {
+ fontWeight: '500',
+ fontSize: ScreenWidth / 28,
+ color: 'white'
+ }
+})
+export default Vote
diff --git a/src/page/Profile/Profile.js b/src/page/Profile/Profile.js
index 17ca0cbf..de100ed3 100755
--- a/src/page/Profile/Profile.js
+++ b/src/page/Profile/Profile.js
@@ -1,219 +1,242 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-19 21:24:18
- */
-import React, { Component } from 'react'
-import { Text, View, ScrollView, Image, TouchableOpacity, SafeAreaView, Platform, StatusBar } from 'react-native'
-
-import Identicon from 'polkadot-identicon-react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../util/Common'
-import i18n from '../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Profile extends Component {
- // 切换到 Manage_Account 页面
- // Switch to the Manage_Account page
- Manage_Account() {
- this.props.navigation.navigate('Manage_Account')
- }
-
- // 切换到通讯录页面
- // Switch to the address book page
- GoAddresses() {
- this.props.rootStore.stateStore.transfer_address = 0
- this.props.navigation.navigate('Addresses')
- }
-
- // 切换到设置页面
- // Switch to the settings page
- Settings() {
- this.props.navigation.navigate('Settings')
- }
-
- // 切换到关于我们页面
- // Switch to the About page
- About() {
- this.props.navigation.navigate('About')
- }
-
- componentDidMount() {
- // 通过addListener开启监听,可以使用上面的四个属性
- // With addListener to enable listening, use the four properties above
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
- this.setState({})
- if (Platform.OS == 'android') {
- StatusBar.setBackgroundColor('#F14B79')
- }
- StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
- })
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- // Unlisten when the page disappears
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- componentWillMount() {
- if (Platform.OS == 'android') {
- StatusBar.setBackgroundColor('#F14B79')
- }
- StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
- }
-
- render() {
- return (
-
-
-
-
-
-
- {i18n.t('TAB.Profile')}
-
-
- {/* 头像 */}
-
- {/* 用户名 */}
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].account}
-
-
-
-
-
-
- {/* 更多 */}
-
- {i18n.t('Profile.ManageAccount')}
-
-
-
-
-
- {i18n.t('Profile.Addresses')}
-
-
-
-
-
- {i18n.t('Profile.Settings')}
-
-
-
-
-
-
- {i18n.t('Profile.About')}
-
-
-
-
-
-
-
- )
- }
-}
-export default Profile
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ Text,
+ View,
+ ScrollView,
+ Image,
+ TouchableOpacity,
+ SafeAreaView,
+ Platform,
+ StatusBar,
+ InteractionManager
+} from 'react-native'
+
+import Identicon from 'polkadot-identicon-react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight } from '../../util/Common'
+import i18n from '../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Profile extends Component {
+ /**
+ * @description 切换到 Manage_Account 页面|Switch to the Manage_Account page
+ */
+ Manage_Account() {
+ this.props.navigation.navigate('Manage_Account')
+ }
+
+ /**
+ * @description 切换到通讯录页面|Switch to the address book page
+ */
+ GoAddresses() {
+ this.props.rootStore.stateStore.transfer_address = 0
+ this.props.navigation.navigate('Addresses')
+ }
+
+ /**
+ * @description 切换到设置页面|Switch to the settings page
+ */
+ Settings() {
+ this.props.navigation.navigate('Settings')
+ }
+
+ /**
+ * @description 切换到关于我们页面|Switch to the About page
+ */
+ About() {
+ this.props.navigation.navigate('About')
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ if (Platform.OS == 'android') {
+ StatusBar.setBackgroundColor('#F14B79')
+ }
+ StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ componentWillMount() {
+ // 通过addListener开启监听,可以使用上面的四个属性
+ // With addListener to enable listening, use the four properties above
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
+ this.setState({})
+ if (Platform.OS == 'android') {
+ StatusBar.setBackgroundColor('#F14B79')
+ }
+ StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
+ })
+ }
+
+ render() {
+ return (
+
+
+
+
+
+
+ {i18n.t('TAB.Profile')}
+
+
+ {/* 头像 | Identicon */}
+
+ {/* 用户名 | User name */}
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].account}
+
+
+
+
+
+
+ {/* 更多 | The more */}
+
+ {i18n.t('Profile.ManageAccount')}
+
+
+
+
+
+ {i18n.t('Profile.Addresses')}
+
+
+
+
+
+ {i18n.t('Profile.Settings')}
+
+
+
+
+
+ {i18n.t('Profile.About')}
+
+
+
+
+
+
+
+ )
+ }
+}
+export default Profile
diff --git a/src/page/Profile/secondary/About.js b/src/page/Profile/secondary/About.js
index 15d74df7..b5a0e49e 100755
--- a/src/page/Profile/secondary/About.js
+++ b/src/page/Profile/secondary/About.js
@@ -1,114 +1,112 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { StyleSheet, Text, View, Image, SafeAreaView, StatusBar } from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import Header from '../../../components/Header'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class About extends Component {
- constructor(props) {
- super(props)
- this.state = {}
- this.back = this.back.bind(this)
- this.Set_Node = this.Set_Node.bind(this)
- }
-
- back() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- Set_Node() {
- this.props.navigation.navigate('Set_Node')
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
- {/* 图标 */}
-
- {/* 简介 */}
-
- {i18n.t('Profile.PolkadotApp')}
-
- {/* 官网 */}
-
- https://polkawallet.io
-
- {/* 版本 */}
-
-
- {i18n.t('Profile.Version')}: 0.1.7
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- msgView: {
- justifyContent: 'center',
- backgroundColor: 'white',
- flexDirection: 'row',
- alignItems: 'center',
- height: ScreenHeight / 18
- },
- msgText: {
- fontSize: ScreenWidth / 25,
- color: '#808080'
- },
- msgImage: {
- marginTop: 200,
- marginBottom: ScreenHeight / 40,
- alignSelf: 'center',
- // height: ScreenHeight / 4,
- // width: ScreenHeight / 4,
- resizeMode: 'contain'
- }
-})
-export default About
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { StyleSheet, Text, View, Image, SafeAreaView, StatusBar } from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight } from '../../../util/Common'
+import Header from '../../../components/Header'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class About extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {}
+ this.back = this.back.bind(this)
+ }
+
+ /**
+ * @description 返回|Click the back
+ */
+ back() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+ {/* 图标 | LOGO */}
+
+ {/* 简介 | Introduction */}
+
+ {i18n.t('Profile.PolkadotApp')}
+
+ {/* 官网 | Website */}
+
+ https://polkawallet.io
+
+ {/* 版本 | Version */}
+
+
+ {i18n.t('Profile.Version')}: 0.1.7
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ msgView: {
+ justifyContent: 'center',
+ backgroundColor: 'white',
+ flexDirection: 'row',
+ alignItems: 'center',
+ height: ScreenHeight / 18
+ },
+ msgText: {
+ fontSize: ScreenWidth / 25,
+ color: '#808080'
+ },
+ msgImage: {
+ marginTop: 200,
+ marginBottom: ScreenHeight / 40,
+ alignSelf: 'center',
+ // height: ScreenHeight / 4,
+ // width: ScreenHeight / 4,
+ resizeMode: 'contain'
+ }
+})
+export default About
diff --git a/src/page/Profile/secondary/AddAddress.js b/src/page/Profile/secondary/AddAddress.js
index 9b5cee7f..533c4262 100755
--- a/src/page/Profile/secondary/AddAddress.js
+++ b/src/page/Profile/secondary/AddAddress.js
@@ -1,233 +1,264 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- Image,
- TouchableOpacity,
- TextInput,
- AsyncStorage,
- StatusBar,
- SafeAreaView,
- Alert
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import Header from '../../../components/Header'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class AddAddress extends Component {
- constructor(props) {
- super(props)
- this.state = {
- name: '',
- memo: '',
- address: ''
- }
- this.back = this.back.bind(this)
- this.save = this.save.bind(this)
- this.onChangeName = this.onChangeName.bind(this)
- this.onChangeMemo = this.onChangeMemo.bind(this)
- this.onChangeAddress = this.onChangeAddress.bind(this)
- this.camrea = this.camrea.bind(this)
- }
-
- back() {
- this.props.rootStore.stateStore.iscamera = 0
- this.props.navigation.navigate('Addresses')
- }
-
- camrea() {
- this.props.rootStore.stateStore.tocamera = 2
- this.props.navigation.navigate('Camera')
- }
-
- onChangeName(ChangeName) {
- this.setState({
- name: ChangeName
- })
- }
-
- onChangeMemo(ChangeMemo) {
- this.setState({
- memo: ChangeMemo
- })
- }
-
- onChangeAddress(ChangeAddress) {
- if (this.props.rootStore.stateStore.iscamera == 1) {
- this.props.rootStore.stateStore.iscamera = 0
- }
- this.setState({
- address: ChangeAddress
- })
- }
-
- save() {
- if (!this.state.name || !this.state.memo || !this.state.address) {
- return Alert.alert('', i18n.t('TAB.enterInformation'))
- }
- AsyncStorage.getItem('Addresses').then(result => {
- if (result == null) {
- AsyncStorage.setItem(
- 'Addresses',
- JSON.stringify([
- {
- Name: this.state.name,
- Memo: this.state.memo,
- Address: this.state.address
- }
- ])
- ).then(() => {
- Alert.alert('', i18n.t('Profile.SaveSuccess'))
- this.props.navigation.navigate('Addresses')
- })
- } else {
- if (this.state.address == '' && this.props.rootStore.stateStore.iscamera == 0) {
- Alert.alert('', i18n.t('TAB.enterInformation'))
- } else {
- let a = JSON.parse(result)
- a.push({
- Name: this.state.name,
- Memo: this.state.memo,
- Address:
- this.props.rootStore.stateStore.iscamera == 0
- ? this.state.address
- : this.props.rootStore.stateStore.QRaddress
- })
- AsyncStorage.setItem('Addresses', JSON.stringify(a)).then(() => {
- this.props.rootStore.stateStore.iscamera = 0
- this.props.navigation.navigate('Tabbed_Navigation')
- })
- }
- }
- })
- }
-
- render() {
- const msg = [i18n.t('Profile.Name'), i18n.t('Profile.Memo'), i18n.t('Profile.Address')]
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
- {msg.map((item, index) => {
- return (
-
- {
-
-
- {index == 2 && (
-
-
-
- )}
-
- }
-
- )
- })}
-
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- save_touch: {
- width: ScreenHeight / 33.35 + ScreenWidth * 0.06,
- justifyContent: 'center',
- alignItems: 'center'
- },
- save_text: {
- color: 'white',
- fontSize: ScreenWidth / 28
- },
- view: {
- justifyContent: 'center',
- height: ScreenHeight / 8
- },
- text: {
- marginLeft: ScreenWidth * 0.06,
- color: 'black',
- fontWeight: '400'
- },
- textInputStyle: {
- color: '#696969',
- width: ScreenWidth - 40,
- fontSize: ScreenHeight / 45
- },
- inputview: {
- flexDirection: 'row',
- alignItems: 'center',
- height: 57,
- borderBottomWidth: 1,
- borderBottomColor: '#ECE2E5',
- width: ScreenWidth - 40
- },
- Change: {
- alignSelf: 'center',
- marginBottom: 80,
- alignItems: 'center',
- justifyContent: 'center'
- }
-})
-export default AddAddress
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ Image,
+ TouchableOpacity,
+ TextInput,
+ AsyncStorage,
+ StatusBar,
+ SafeAreaView,
+ Alert
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, doubleClick } from '../../../util/Common'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import Header from '../../../components/Header'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class AddAddress extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ name: '',
+ memo: '',
+ address: ''
+ }
+ this.back = this.back.bind(this)
+ this.save = this.save.bind(this)
+ this.onChangeName = this.onChangeName.bind(this)
+ this.onChangeMemo = this.onChangeMemo.bind(this)
+ this.onChangeAddress = this.onChangeAddress.bind(this)
+ this.camrea = this.camrea.bind(this)
+ }
+
+ /**
+ * @description 返回|Click the back
+ */
+ back() {
+ this.props.rootStore.stateStore.iscamera = 0
+ this.props.navigation.navigate('Addresses')
+ }
+
+ /**
+ * @description 切换扫描页面|Switch scan page
+ */
+ camrea() {
+ this.props.rootStore.stateStore.tocamera = 2
+ this.props.navigation.navigate('Camera')
+ }
+
+ /**
+ * @description 更换名称|Change name
+ * @param {String} ChangeName 更换的名称|The name to change
+ */
+ onChangeName(ChangeName) {
+ this.setState({
+ name: ChangeName
+ })
+ }
+
+ /**
+ * @description 更改备注|Change memo
+ * @param {String} ChangeMemo 更换的备注|The memo to change
+ */
+ onChangeMemo(ChangeMemo) {
+ this.setState({
+ memo: ChangeMemo
+ })
+ }
+
+ /**
+ * @description 更改地址|Change address
+ * @param {String} ChangeAddress 地址|Address
+ */
+ onChangeAddress(ChangeAddress) {
+ if (this.props.rootStore.stateStore.iscamera == 1) {
+ this.props.rootStore.stateStore.iscamera = 0
+ }
+ this.setState({
+ address: ChangeAddress
+ })
+ }
+
+ /**
+ * @description 最后点击保存|Click the save
+ */
+ save() {
+ if (!this.state.name || !this.state.memo || !this.state.address) {
+ return Alert.alert('', i18n.t('TAB.enterInformation'))
+ }
+ AsyncStorage.getItem('Addresses').then(result => {
+ if (result == null) {
+ AsyncStorage.setItem(
+ 'Addresses',
+ JSON.stringify([
+ {
+ Name: this.state.name,
+ Memo: this.state.memo,
+ Address: this.state.address
+ }
+ ])
+ ).then(() => {
+ Alert.alert('', i18n.t('Profile.SaveSuccess'))
+ this.props.navigation.navigate('Addresses')
+ })
+ } else {
+ if (this.state.address == '' && this.props.rootStore.stateStore.iscamera == 0) {
+ Alert.alert('', i18n.t('TAB.enterInformation'))
+ } else {
+ let a = JSON.parse(result)
+ a.push({
+ Name: this.state.name,
+ Memo: this.state.memo,
+ Address:
+ this.props.rootStore.stateStore.iscamera == 0
+ ? this.state.address
+ : this.props.rootStore.stateStore.QRaddress
+ })
+ AsyncStorage.setItem('Addresses', JSON.stringify(a)).then(() => {
+ this.props.rootStore.stateStore.iscamera = 0
+ this.props.navigation.navigate('Tabbed_Navigation')
+ })
+ }
+ }
+ })
+ }
+
+ render() {
+ const msg = [i18n.t('Profile.Name'), i18n.t('Profile.Memo'), i18n.t('Profile.Address')]
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+ {msg.map((item, index) => {
+ return (
+
+ {
+
+
+ {index == 2 && (
+
+
+
+ )}
+
+ }
+
+ )
+ })}
+
+
+ {
+ doubleClick(this.save)
+ }}
+ activeOpacity={0.7}
+ >
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ save_touch: {
+ width: ScreenHeight / 33.35 + ScreenWidth * 0.06,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ save_text: {
+ color: 'white',
+ fontSize: ScreenWidth / 28
+ },
+ view: {
+ justifyContent: 'center',
+ height: ScreenHeight / 8
+ },
+ text: {
+ marginLeft: ScreenWidth * 0.06,
+ color: 'black',
+ fontWeight: '400'
+ },
+ textInputStyle: {
+ color: '#696969',
+ width: ScreenWidth - 40,
+ fontSize: ScreenHeight / 45
+ },
+ inputview: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ height: 57,
+ borderBottomWidth: 1,
+ borderBottomColor: '#ECE2E5',
+ width: ScreenWidth - 40
+ },
+ Change: {
+ alignSelf: 'center',
+ marginBottom: 80,
+ alignItems: 'center',
+ justifyContent: 'center'
+ }
+})
+export default AddAddress
diff --git a/src/page/Profile/secondary/AddressInformation.js b/src/page/Profile/secondary/AddressInformation.js
index 8884c28e..e3791713 100755
--- a/src/page/Profile/secondary/AddressInformation.js
+++ b/src/page/Profile/secondary/AddressInformation.js
@@ -1,229 +1,243 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- Clipboard,
- Alert,
- AsyncStorage,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import Header from '../../../components/Header'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class AddressInformation extends Component {
- constructor(props) {
- super(props)
- this.state = {
- is: false,
- s: 1,
- index: this.props.navigation.state.params.index
- }
- this.back = this.back.bind(this)
- this.save = this.save.bind(this)
- this.copy = this.copy.bind(this)
- this.delete = this.delete.bind(this)
- }
-
- back() {
- this.props.navigation.navigate('Addresses')
- }
-
- save() {
- return null
- }
-
- copy() {
- Clipboard.setString(this.props.rootStore.stateStore.Addresses[this.state.index].Address)
- Alert.alert('', i18n.t('TAB.CopySuccess'))
- }
-
- delete() {
- Alert.alert(
- '',
- i18n.t('Profile.deleteTip'),
- [
- {
- text: 'Cancel',
- onPress: () => console.log('Cancel Pressed'),
- style: 'cancel'
- },
- {
- text: 'OK',
- onPress: () => {
- let addresses = []
- AsyncStorage.getItem('Addresses').then(result => {
- if (result != null) {
- JSON.parse(result).map((item, index) => {
- if (index != this.state.index) {
- addresses.push(item)
- }
- })
- AsyncStorage.setItem('Addresses', JSON.stringify(addresses)).then(
- this.props.navigation.navigate('Tabbed_Navigation')
- )
- }
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
-
- render() {
- const msg = [{ key: i18n.t('Profile.Name') }, { key: i18n.t('Profile.Memo') }, { key: i18n.t('Profile.Address') }]
- return (
-
- {/* 标题栏 | Title bar */}
-
-
-
- {msg.map((item, index) => {
- return (
-
- {/* {item.key} */}
-
-
-
- {index == 2 ? (
-
- {this.props.rootStore.stateStore.Addresses[this.state.index].Address}
-
- ) : (
-
- {index == 0
- ? this.props.rootStore.stateStore.Addresses[this.state.index].Name
- : this.props.rootStore.stateStore.Addresses[this.state.index].Memo}
-
- )}
-
- {index == 2 && (
-
-
-
- )}
-
-
- )
- })}
-
-
-
- {i18n.t('Profile.DeleteAddress')}
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- save_touch: {
- width: ScreenHeight / 33.35 + ScreenWidth * 0.06,
- justifyContent: 'center',
- alignItems: 'center'
- },
- save_text: {
- color: 'white',
- fontSize: ScreenWidth / 28
- },
- view: {
- justifyContent: 'center',
- alignItems: 'center',
- height: ScreenHeight / 8
- },
- text: {
- marginLeft: ScreenWidth * 0.06,
- color: 'black',
- fontWeight: '400'
- },
- textInputStyle: {
- color: '#696969',
- width: ScreenWidth - 40,
- fontSize: ScreenHeight / 45
- },
- inputview: {
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'center',
- height: 57,
- borderBottomWidth: 1,
- borderBottomColor: '#ECE2E5',
- width: ScreenWidth - 40
- },
- Change: {
- alignSelf: 'center',
- marginBottom: 80,
- alignItems: 'center',
- justifyContent: 'center'
- },
- delete: {
- height: ScreenHeight / 8,
- width: ScreenWidth,
- justifyContent: 'center',
- alignItems: 'center'
- }
-})
-export default AddressInformation
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ Clipboard,
+ Alert,
+ AsyncStorage,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, doubleClick } from '../../../util/Common'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import Header from '../../../components/Header'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class AddressInformation extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ is: false,
+ s: 1,
+ index: this.props.navigation.state.params.index
+ }
+ this.back = this.back.bind(this)
+ this.copy = this.copy.bind(this)
+ this.delete = this.delete.bind(this)
+ }
+
+ /**
+ * @description 返回|Click the back
+ */
+ back() {
+ this.props.navigation.navigate('Addresses')
+ }
+
+ /**
+ * @description 复制|Click the copy
+ */
+ copy() {
+ Clipboard.setString(this.props.rootStore.stateStore.Addresses[this.state.index].Address)
+ Alert.alert('', i18n.t('TAB.CopySuccess'))
+ }
+
+ /**
+ * @description 删除|Click the delete
+ */
+ delete() {
+ Alert.alert(
+ '',
+ i18n.t('Profile.deleteTip'),
+ [
+ {
+ text: 'Cancel',
+ onPress: () => {},
+ style: 'cancel'
+ },
+ {
+ text: 'OK',
+ onPress: () => {
+ let addresses = []
+ AsyncStorage.getItem('Addresses').then(result => {
+ if (result != null) {
+ JSON.parse(result).map((item, index) => {
+ if (index != this.state.index) {
+ addresses.push(item)
+ }
+ })
+ AsyncStorage.setItem('Addresses', JSON.stringify(addresses)).then(
+ this.props.navigation.navigate('Tabbed_Navigation')
+ )
+ }
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+
+ render() {
+ const msg = [{ key: i18n.t('Profile.Name') }, { key: i18n.t('Profile.Memo') }, { key: i18n.t('Profile.Address') }]
+ return (
+
+ {/* 标题栏 | Title bar */}
+
+
+
+ {msg.map((item, index) => {
+ return (
+
+ {/* {item.key} */}
+
+
+
+ {index == 2 ? (
+
+ {this.props.rootStore.stateStore.Addresses[this.state.index].Address}
+
+ ) : (
+
+ {index == 0
+ ? this.props.rootStore.stateStore.Addresses[this.state.index].Name
+ : this.props.rootStore.stateStore.Addresses[this.state.index].Memo}
+
+ )}
+
+ {index == 2 && (
+ {
+ doubleClick(this.copy)
+ }}
+ activeOpacity={0.7}
+ >
+
+
+ )}
+
+
+ )
+ })}
+
+
+ {
+ doubleClick(this.delete)
+ }}
+ activeOpacity={0.7}
+ >
+ {i18n.t('Profile.DeleteAddress')}
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ save_touch: {
+ width: ScreenHeight / 33.35 + ScreenWidth * 0.06,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ save_text: {
+ color: 'white',
+ fontSize: ScreenWidth / 28
+ },
+ view: {
+ justifyContent: 'center',
+ alignItems: 'center',
+ height: ScreenHeight / 8
+ },
+ text: {
+ marginLeft: ScreenWidth * 0.06,
+ color: 'black',
+ fontWeight: '400'
+ },
+ textInputStyle: {
+ color: '#696969',
+ width: ScreenWidth - 40,
+ fontSize: ScreenHeight / 45
+ },
+ inputview: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'center',
+ height: 57,
+ borderBottomWidth: 1,
+ borderBottomColor: '#ECE2E5',
+ width: ScreenWidth - 40
+ },
+ Change: {
+ alignSelf: 'center',
+ marginBottom: 80,
+ alignItems: 'center',
+ justifyContent: 'center'
+ },
+ delete: {
+ height: ScreenHeight / 8,
+ width: ScreenWidth,
+ justifyContent: 'center',
+ alignItems: 'center'
+ }
+})
+export default AddressInformation
diff --git a/src/page/Profile/secondary/Addresses.js b/src/page/Profile/secondary/Addresses.js
index 0ad08033..bfb2e702 100755
--- a/src/page/Profile/secondary/Addresses.js
+++ b/src/page/Profile/secondary/Addresses.js
@@ -1,194 +1,216 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- ScrollView,
- Image,
- TouchableOpacity,
- AsyncStorage,
- StatusBar,
- Platform,
- SafeAreaView
-} from 'react-native'
-import Identicon from 'polkadot-identicon-react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import Header from '../../../components/Header'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Addresses extends Component {
- constructor(props) {
- super(props)
- this.state = {
- is: false,
- s: 1,
- index: 0
- }
- this.back = this.back.bind(this)
- this.add_address = this.add_address.bind(this)
- }
-
- back() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- add_address() {
- this.props.navigation.navigate('Add_address')
- }
-
- componentDidMount() {
- // 通过addListener开启监听,可以使用上面的四个属性
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
- this.onDidFocus()
- })
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- onDidFocus() {
- this.props.rootStore.stateStore.Addresses = []
- AsyncStorage.getItem('Addresses').then(result => {
- if (result != null) {
- JSON.parse(result).map((item, index) => {
- this.props.rootStore.stateStore.Addresses.push(item)
- })
- }
- })
- }
-
- render() {
- return (
-
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
- {// Addresses.map((item,index)=>{
- this.props.rootStore.stateStore.Addresses.map((item, index) => {
- return (
- {
- if (this.props.rootStore.stateStore.transfer_address == 0) {
- this.props.navigation.navigate('Address_information', {
- index: index
- })
- } else {
- this.props.rootStore.stateStore.t_address = item.Address
- this.props.rootStore.stateStore.isaddresses = 1
- this.props.navigation.navigate('Transfer')
- }
- }}
- >
- {/* 头像 */}
-
- {/* 信息 */}
-
- {item.Name}
-
- {item.Address}
-
-
- {i18n.t('Profile.Memo')}:{item.Memo}
-
-
- {/* 查看详细信息 */}
-
-
- )
- })}
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- view: {
- borderBottomWidth: 1,
- borderBottomColor: '#E5E5E5',
- flexDirection: 'row',
- alignItems: 'center',
- height: 80
- },
- image: {
- marginLeft: 20
- },
- text: {
- marginLeft: ScreenWidth * 0.02,
- flex: 1,
- justifyContent: 'center'
- },
- text1: {
- fontSize: 18,
- color: '#3E2D32'
- // marginBottom: 12
- },
- text2: {
- fontSize: 14,
- color: '#AAAAAA'
- },
- text3: {
- width: ScreenWidth * 0.5,
- fontSize: 14,
- color: '#3E2D32'
- // marginBottom: 6
- },
- next: {
- marginRight: ScreenWidth / 28,
- height: ScreenHeight / 60,
- width: ScreenHeight / 60 / 1.83,
- resizeMode: 'contain'
- }
-})
-export default Addresses
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ ScrollView,
+ Image,
+ TouchableOpacity,
+ AsyncStorage,
+ StatusBar,
+ Platform,
+ SafeAreaView,
+ InteractionManager
+} from 'react-native'
+import Identicon from 'polkadot-identicon-react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight } from '../../../util/Common'
+import Header from '../../../components/Header'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Addresses extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ is: false,
+ s: 1,
+ index: 0
+ }
+ this.back = this.back.bind(this)
+ this.add_address = this.add_address.bind(this)
+ }
+
+ /**
+ * @description 返回|Click the back
+ */
+ back() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 切换 Add_address 页面|Switch to the Add_address page
+ */
+ add_address() {
+ this.props.navigation.navigate('Add_address')
+ }
+
+ componentDidMount() {
+ // 通过addListener开启监听,可以使用上面的四个属性
+ // With addListener to enable listening, can use the four properties above
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', payload => {
+ InteractionManager.runAfterInteractions(() => {
+ this.onDidFocus()
+ })
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ /**
+ * @description 页面获得焦点|Page gets focus
+ */
+ onDidFocus() {
+ this.props.rootStore.stateStore.Addresses = []
+ AsyncStorage.getItem('Addresses').then(result => {
+ if (result != null) {
+ JSON.parse(result).map((item, index) => {
+ this.props.rootStore.stateStore.Addresses.push(item)
+ })
+ }
+ })
+ }
+
+ render() {
+ return (
+
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+ {// Addresses.map((item,index)=>{
+ this.props.rootStore.stateStore.Addresses.map((item, index) => {
+ return (
+ {
+ if (this.props.rootStore.stateStore.transfer_address == 0) {
+ this.props.navigation.navigate('Address_information', {
+ index: index
+ })
+ } else {
+ this.props.rootStore.stateStore.t_address = item.Address
+ this.props.rootStore.stateStore.isaddresses = 1
+ this.props.navigation.navigate('Transfer')
+ }
+ }}
+ >
+ {/* 头像 | Identicon */}
+
+ {/* 信息 | info */}
+
+ {item.Name}
+
+ {item.Address}
+
+
+ {i18n.t('Profile.Memo')}:{item.Memo}
+
+
+ {/* 查看详细信息 | View details */}
+
+
+ )
+ })}
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ view: {
+ borderBottomWidth: 1,
+ borderBottomColor: '#E5E5E5',
+ flexDirection: 'row',
+ alignItems: 'center',
+ height: 80
+ },
+ image: {
+ marginLeft: 20
+ },
+ text: {
+ marginLeft: ScreenWidth * 0.02,
+ flex: 1,
+ justifyContent: 'center'
+ },
+ text1: {
+ fontSize: 18,
+ color: '#3E2D32'
+ // marginBottom: 12
+ },
+ text2: {
+ fontSize: 14,
+ color: '#AAAAAA'
+ },
+ text3: {
+ width: ScreenWidth * 0.5,
+ fontSize: 14,
+ color: '#3E2D32'
+ // marginBottom: 6
+ },
+ next: {
+ marginRight: ScreenWidth / 28,
+ height: ScreenHeight / 60,
+ width: ScreenHeight / 60 / 1.83,
+ resizeMode: 'contain'
+ }
+})
+export default Addresses
diff --git a/src/page/Profile/secondary/Change/ChangeName.js b/src/page/Profile/secondary/Change/ChangeName.js
index 3ae10bc8..e99fb3c8 100755
--- a/src/page/Profile/secondary/Change/ChangeName.js
+++ b/src/page/Profile/secondary/Change/ChangeName.js
@@ -1,234 +1,258 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- TextInput,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, checkPwd } from '../../../../util/Common'
-import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
-import i18n from '../../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class ChangeName extends Component {
- constructor(props) {
- super(props)
- this.json
- this.state = {
- New_name: '',
- Current_password: ''
- }
- this.back = this.back.bind(this)
- this.Change_Name = this.Change_Name.bind(this)
- this.Change = this.Change.bind(this)
- this.Current_password = this.Current_password.bind(this)
- }
-
- back() {
- this.props.navigation.navigate('Manage_Account')
- }
-
- Current_password(Current_password) {
- this.setState({
- Current_password: Current_password
- })
- }
-
- Change_Name(New_name) {
- this.setState({
- New_name: New_name
- })
- }
-
- Change() {
- if (!this.state.Current_password) {
- Alert.alert('', i18n.t('Profile.entPwd'))
- } else if (!this.state.New_name) {
- Alert.alert('', i18n.t('Profile.entName'))
- } else {
- const _this = this
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.Current_password,
- success: (loadPair, SInfo) => {
- loadPair.setMeta({ name: _this.state.New_name })
- _this.json = loadPair.toJson(_this.state.Current_password)
- _this.json.meta = loadPair.getMeta()
- SInfo.setItem(
- _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- JSON.stringify(_this.json),
- {
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- }
- )
- _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].account =
- _this.state.New_name
- Alert.alert(
- '',
- i18n.t('Profile.Modify'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Manage_Account')
- }
- }
- ],
- { cancelable: false }
- )
- }
- })
- }
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
-
-
- {i18n.t('Profile.ChangeName')}
-
-
- {/* Current password */}
-
-
-
- {/* New name */}
-
-
-
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- save_touch: {
- width: ScreenHeight / 33.35 + ScreenWidth * 0.06,
- justifyContent: 'center',
- alignItems: 'center'
- },
- save_text: {
- color: 'white',
- fontSize: ScreenWidth / 28
- },
- view: {
- width: ScreenWidth - 40,
- alignItems: 'center',
- justifyContent: 'center',
- height: 57
- },
- text: {
- fontSize: ScreenWidth / 25,
- width: ScreenWidth * 0.8,
- color: '#696969',
- fontWeight: '400'
- },
- textInputStyle: {
- width: ScreenWidth - 40,
- color: '#AAAAAA',
- borderBottomWidth: 1,
- borderBottomColor: '#ECE2E5',
- fontSize: 16
- },
- inputview: {
- marginTop: ScreenHeight / 70,
- flexDirection: 'row',
- alignItems: 'center'
- },
- inputimage: {
- marginLeft: ScreenWidth * 0.02,
- height: ScreenWidth * 0.04,
- width: ScreenWidth * 0.04,
- resizeMode: 'contain'
- },
- Change: {
- alignSelf: 'center',
- marginBottom: 80,
- alignItems: 'center',
- justifyContent: 'center'
- }
-})
-export default ChangeName
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ TextInput,
+ Alert,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, checkPwd, doubleClick } from '../../../../util/Common'
+import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
+import i18n from '../../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class ChangeName extends Component {
+ constructor(props) {
+ super(props)
+ this.json
+ this.state = {
+ New_name: '',
+ Current_password: ''
+ }
+ this.back = this.back.bind(this)
+ this.Change_Name = this.Change_Name.bind(this)
+ this.Change = this.Change.bind(this)
+ this.Current_password = this.Current_password.bind(this)
+ }
+
+ /**
+ * @description 点击返回|Click the back
+ */
+ back() {
+ this.props.navigation.navigate('Manage_Account')
+ }
+
+ /**
+ * @description 当前密码修改|Change of current password
+ * @param {String} Current_password 当前密码|Current password
+ */
+ Current_password(Current_password) {
+ this.setState({
+ Current_password: Current_password
+ })
+ }
+
+ /**
+ * @description 名称的修改|Change of name
+ * @param {String} New_name 名称|name
+ */
+ Change_Name(New_name) {
+ this.setState({
+ New_name: New_name
+ })
+ }
+
+ /**
+ * @description 提交修改|Submit the change
+ */
+ Change() {
+ if (!this.state.Current_password) {
+ Alert.alert('', i18n.t('Profile.entPwd'))
+ } else if (!this.state.New_name) {
+ Alert.alert('', i18n.t('Profile.entName'))
+ } else {
+ const _this = this
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.Current_password,
+ success: (loadPair, SInfo) => {
+ loadPair.setMeta({ name: _this.state.New_name })
+ _this.json = loadPair.toJson(_this.state.Current_password)
+ _this.json.meta = loadPair.getMeta()
+ SInfo.setItem(
+ _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ JSON.stringify(_this.json),
+ {
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ }
+ )
+ _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].account =
+ _this.state.New_name
+ Alert.alert(
+ '',
+ i18n.t('Profile.Modify'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Manage_Account')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ })
+ }
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+
+
+ {i18n.t('Profile.ChangeName')}
+
+
+ {/* Current password */}
+
+
+
+ {/* New name */}
+
+
+
+ {
+ doubleClick(this.Change)
+ }}
+ activeOpacity={0.7}
+ >
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ save_touch: {
+ width: ScreenHeight / 33.35 + ScreenWidth * 0.06,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ save_text: {
+ color: 'white',
+ fontSize: ScreenWidth / 28
+ },
+ view: {
+ width: ScreenWidth - 40,
+ alignItems: 'center',
+ justifyContent: 'center',
+ height: 57
+ },
+ text: {
+ fontSize: ScreenWidth / 25,
+ width: ScreenWidth * 0.8,
+ color: '#696969',
+ fontWeight: '400'
+ },
+ textInputStyle: {
+ width: ScreenWidth - 40,
+ color: '#AAAAAA',
+ borderBottomWidth: 1,
+ borderBottomColor: '#ECE2E5',
+ fontSize: 16
+ },
+ inputview: {
+ marginTop: ScreenHeight / 70,
+ flexDirection: 'row',
+ alignItems: 'center'
+ },
+ inputimage: {
+ marginLeft: ScreenWidth * 0.02,
+ height: ScreenWidth * 0.04,
+ width: ScreenWidth * 0.04,
+ resizeMode: 'contain'
+ },
+ Change: {
+ alignSelf: 'center',
+ marginBottom: 80,
+ alignItems: 'center',
+ justifyContent: 'center'
+ }
+})
+export default ChangeName
diff --git a/src/page/Profile/secondary/Change/ChangePassword.js b/src/page/Profile/secondary/Change/ChangePassword.js
index b605415c..946db323 100755
--- a/src/page/Profile/secondary/Change/ChangePassword.js
+++ b/src/page/Profile/secondary/Change/ChangePassword.js
@@ -1,264 +1,292 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- TextInput,
- StatusBar,
- SafeAreaView,
- Alert
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, checkPwd } from '../../../../util/Common'
-import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
-import i18n from '../../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class ChangePassword extends Component {
- constructor(props) {
- super(props)
- this.json
- this.state = {
- Current_password: '',
- New_password: '',
- Repeat_password: '',
- ispwd1: 0,
- ispwd2: 0,
- ispwd3: 0
- }
- this.back = this.back.bind(this)
- this.Current_password = this.Current_password.bind(this)
- this.New_password = this.New_password.bind(this)
- this.Repeat_password = this.Repeat_password.bind(this)
- this.Change = this.Change.bind(this)
- }
-
- back() {
- this.props.navigation.navigate('Manage_Account')
- }
-
- Current_password(Current_password) {
- if (Current_password != '') {
- this.setState({ ispwd1: 1 })
- }
- if (Current_password == '') {
- this.setState({ ispwd1: 0 })
- }
- this.setState({
- Current_password: Current_password
- })
- }
-
- New_password(New_password) {
- if (New_password != '') {
- this.setState({ ispwd2: 1 })
- }
- if (New_password == '') {
- this.setState({ ispwd2: 0 })
- }
- this.setState({
- New_password: New_password
- })
- }
-
- Repeat_password(Repeat_password) {
- if (Repeat_password != this.state.New_password) {
- this.setState({ ispwd3: 0 })
- }
- if (Repeat_password == this.state.New_password) {
- this.setState({ ispwd3: 1 })
- }
- this.setState({
- Repeat_password: Repeat_password
- })
- }
-
- Change() {
- if (this.state.New_password != this.state.Repeat_password) {
- Alert.alert('', 'The two passwords are different')
- } else {
- const _this = this
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.New_password,
- success: (loadPair, SInfo) => {
- _this.json = loadPair.toJson(_this.state.New_password)
- SInfo.setItem(
- _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- JSON.stringify(_this.json),
- {
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- }
- )
- Alert.alert(
- '',
- i18n.t('Profile.Modify'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Manage_Account')
- }
- }
- ],
- { cancelable: false }
- )
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- }
- }
-
- render() {
- const msg = [i18n.t('Profile.CurrentPassword'), i18n.t('Profile.NewPassword'), i18n.t('Profile.RepeatPassword')]
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
-
-
-
- {i18n.t('Profile.ChangePassword')}
-
- {msg.map((item, index) => {
- return (
-
-
-
- )
- })}
-
-
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- save_touch: {
- width: ScreenHeight / 33.35 + ScreenWidth * 0.06,
- justifyContent: 'center',
- alignItems: 'center'
- },
- save_text: {
- color: 'white',
- fontSize: ScreenWidth / 28
- },
- view: {
- width: ScreenWidth - 40,
- alignItems: 'center',
- justifyContent: 'center',
- height: 57,
- marginTop: 11
- },
- text: {
- fontSize: ScreenWidth / 25,
- width: ScreenWidth * 0.8,
- color: '#696969',
- fontWeight: '400'
- },
- textInputStyle: {
- width: ScreenWidth - 40,
- color: '#AAAAAA',
- borderBottomWidth: 1,
- borderBottomColor: '#ECE2E5',
- fontSize: 16
- },
- inputview: {
- marginTop: ScreenHeight / 70,
- flexDirection: 'row',
- alignItems: 'center'
- },
- inputimage: {
- marginLeft: ScreenWidth * 0.02,
- height: ScreenWidth * 0.04,
- width: ScreenWidth * 0.04,
- resizeMode: 'contain'
- },
- Change: {
- alignSelf: 'center',
- marginBottom: 80,
- alignItems: 'center',
- justifyContent: 'center'
- }
-})
-export default ChangePassword
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ TextInput,
+ StatusBar,
+ SafeAreaView,
+ Alert
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, checkPwd, doubleClick } from '../../../../util/Common'
+import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
+import i18n from '../../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class ChangePassword extends Component {
+ constructor(props) {
+ super(props)
+ this.json
+ this.state = {
+ Current_password: '',
+ New_password: '',
+ Repeat_password: '',
+ ispwd1: 0,
+ ispwd2: 0,
+ ispwd3: 0
+ }
+ this.back = this.back.bind(this)
+ this.Current_password = this.Current_password.bind(this)
+ this.New_password = this.New_password.bind(this)
+ this.Repeat_password = this.Repeat_password.bind(this)
+ this.Change = this.Change.bind(this)
+ }
+
+ /**
+ * @description 返回|Click the back
+ */
+ back() {
+ this.props.navigation.navigate('Manage_Account')
+ }
+
+ /**
+ * @description 当前密码修改|Change of current password
+ * @param {String} Current_password 当前密码|Current password
+ */
+ Current_password(Current_password) {
+ if (Current_password != '') {
+ this.setState({ ispwd1: 1 })
+ }
+ if (Current_password == '') {
+ this.setState({ ispwd1: 0 })
+ }
+ this.setState({
+ Current_password: Current_password
+ })
+ }
+
+ /**
+ * @description 新密码修改|Change of new password
+ * @param {String} New_password 新密码|Now password
+ */
+ New_password(New_password) {
+ if (New_password != '') {
+ this.setState({ ispwd2: 1 })
+ }
+ if (New_password == '') {
+ this.setState({ ispwd2: 0 })
+ }
+ this.setState({
+ New_password: New_password
+ })
+ }
+
+ /**
+ * @description 重复密码修改|Change of repeat password
+ * @param {String} Repeat_password 重复新密码| The repeat password
+ */
+ Repeat_password(Repeat_password) {
+ if (Repeat_password != this.state.New_password) {
+ this.setState({ ispwd3: 0 })
+ }
+ if (Repeat_password == this.state.New_password) {
+ this.setState({ ispwd3: 1 })
+ }
+ this.setState({
+ Repeat_password: Repeat_password
+ })
+ }
+
+ /**
+ * @description 密码修改的最后提交|Submit the password
+ */
+ Change() {
+ if (this.state.New_password != this.state.Repeat_password) {
+ Alert.alert('', 'The two passwords are different')
+ } else {
+ const _this = this
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.New_password,
+ success: (loadPair, SInfo) => {
+ _this.json = loadPair.toJson(_this.state.New_password)
+ SInfo.setItem(
+ _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ JSON.stringify(_this.json),
+ {
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ }
+ )
+ Alert.alert(
+ '',
+ i18n.t('Profile.Modify'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Manage_Account')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ }
+ }
+
+ render() {
+ const msg = [i18n.t('Profile.CurrentPassword'), i18n.t('Profile.NewPassword'), i18n.t('Profile.RepeatPassword')]
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+
+
+
+ {i18n.t('Profile.ChangePassword')}
+
+ {msg.map((item, index) => {
+ return (
+
+
+
+ )
+ })}
+
+
+ {
+ doubleClick(this.Change)
+ }}
+ activeOpacity={0.7}
+ >
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ save_touch: {
+ width: ScreenHeight / 33.35 + ScreenWidth * 0.06,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ save_text: {
+ color: 'white',
+ fontSize: ScreenWidth / 28
+ },
+ view: {
+ width: ScreenWidth - 40,
+ alignItems: 'center',
+ justifyContent: 'center',
+ height: 57,
+ marginTop: 11
+ },
+ text: {
+ fontSize: ScreenWidth / 25,
+ width: ScreenWidth * 0.8,
+ color: '#696969',
+ fontWeight: '400'
+ },
+ textInputStyle: {
+ width: ScreenWidth - 40,
+ color: '#AAAAAA',
+ borderBottomWidth: 1,
+ borderBottomColor: '#ECE2E5',
+ fontSize: 16
+ },
+ inputview: {
+ marginTop: ScreenHeight / 70,
+ flexDirection: 'row',
+ alignItems: 'center'
+ },
+ inputimage: {
+ marginLeft: ScreenWidth * 0.02,
+ height: ScreenWidth * 0.04,
+ width: ScreenWidth * 0.04,
+ resizeMode: 'contain'
+ },
+ Change: {
+ alignSelf: 'center',
+ marginBottom: 80,
+ alignItems: 'center',
+ justifyContent: 'center'
+ }
+})
+export default ChangePassword
diff --git a/src/page/Profile/secondary/ManageAccount.js b/src/page/Profile/secondary/ManageAccount.js
index ee94a2f0..a8adc96c 100755
--- a/src/page/Profile/secondary/ManageAccount.js
+++ b/src/page/Profile/secondary/ManageAccount.js
@@ -1,501 +1,542 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- Alert,
- Modal,
- TextInput,
- Clipboard,
- Platform,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import Identicon from 'polkadot-identicon-react-native'
-import SInfo from 'react-native-sensitive-info'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class ManageAccount extends Component {
- constructor(props) {
- super(props)
- this.state = {
- password: '',
- address: this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address,
- isModal1: false,
- isModal2: false,
- msg: ''
- }
- this.ExportKey = this.ExportKey.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.cancel = this.cancel.bind(this)
- this.delete_account = this.delete_account.bind(this)
- this.Continue = this.Continue.bind(this)
- this.Copy = this.Copy.bind(this)
- this.Change_Password = this.Change_Password.bind(this)
- this.Change_Name = this.Change_Name.bind(this)
- }
-
- // 切换到更改账户
- // Switch to Change_Name page
- Change_Name() {
- this.props.navigation.navigate('Change_Name')
- }
-
- // 切换到更改密码
- // Switch to Change_Password page
- Change_Password() {
- this.props.navigation.navigate('Change_Password')
- }
-
- // 导出 key store
- // Export key store
- ExportKey() {
- this.setState({
- isModal1: true
- })
- }
-
- // 密码修改
- // Change password
- onChangepassword(changepassword) {
- this.setState({
- password: changepassword
- })
- }
-
- // 点击取消
- // Click Cancel
- cancel() {
- this.setState({
- password: '',
- isModal1: false
- })
- }
-
- // 点击提交
- // Submit
- ok() {
- checkPwd({
- address: this.state.address,
- password: this.state.password,
- success: () => {
- this.setState({
- isModal1: false,
- isModal2: true
- })
- }
- })
- }
-
- Continue() {
- this.setState({
- password: '',
- isModal2: false
- })
- }
-
- async Copy() {
- Clipboard.setString(this.state.msg)
- Alert.alert('', i18n.t('TAB.CopySuccess'))
- }
-
- // 删除账户
- // Delete account
- delete_account() {
- Alert.alert(
- '',
- i18n.t('Profile.deleteTip'),
- [
- {
- text: 'Cancel',
- onPress: () => console.log('Cancel Pressed'),
- style: 'cancel'
- },
- {
- text: 'OK',
- onPress: () => {
- SInfo.deleteItem(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address,
- {
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- }
- ).then(
- Alert.alert(
- '',
- i18n.t('Profile.DeleteSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- this.props.rootStore.stateStore.Account = 1
- SInfo.getAllItems({
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- }).then(result => {
- if (JSON.stringify(result).length < 10) {
- this.props.rootStore.stateStore.Account = 0
- this.props.rootStore.stateStore.Accountnum = 0
- this.props.rootStore.stateStore.Accounts = [
- {
- account: 'NeedCreate',
- address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
- }
- ]
- this.props.navigation.navigate('Create_Account')
- } else {
- this.props.rootStore.stateStore.Account = 0
- this.props.rootStore.stateStore.Accountnum = 0
- this.props.rootStore.stateStore.Accounts = [
- {
- account: 'NeedCreate',
- address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
- }
- ]
-
- if (Platform.OS == 'android') {
- // android
- for (let o in result) {
- this.props.rootStore.stateStore.Accounts.push({
- account: JSON.parse(result[o]).meta.name,
- address: JSON.parse(result[o]).address
- })
- this.props.rootStore.stateStore.Account++
- this.props.rootStore.stateStore.Accountnum++
- }
- } else {
- // ios
- result.map((item, index) => {
- item.map((item, index) => {
- // 添加用户到 mobx
- // Add account to mobx
- this.props.rootStore.stateStore.Accounts.push({
- account: JSON.parse(item.value).meta.name,
- address: item.key
- })
- this.props.rootStore.stateStore.Account = 1
- this.props.rootStore.stateStore.Accountnum++
- })
- })
- }
- this.props.rootStore.stateStore.balances.map((item, index) => {
- if (
- item.address ==
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- ) {
- this.props.rootStore.stateStore.balanceIndex = index
- }
- })
- this.props.navigation.navigate('Tabbed_Navigation')
- }
- })
- }
- }
- ],
- { cancelable: false }
- )
- )
- }
- }
- ],
- { cancelable: false }
- )
- }
-
- componentWillMount() {
- SInfo.getItem(this.state.address, {
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- }).then(result => {
- this.setState({
- msg: result
- })
- })
- }
-
- render() {
- return (
-
-
-
- {/* The title */}
-
-
-
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
-
-
- {/* Change Name */}
-
-
- {i18n.t('Profile.ChangeName')}
-
-
-
-
- {/* Change password */}
-
-
- {i18n.t('Profile.ChangePassword')}
-
-
-
-
- {/* Export Keystore */}
-
-
- {i18n.t('Profile.ExportKeystore')}
-
-
-
-
-
- {/* delete account */}
-
-
-
- {i18n.t('Profile.DeleteAccount')}
-
-
-
- {/* Please enter your password */}
-
-
-
- {i18n.t('Profile.unlockPassword')}
-
- {/* */}
-
-
- cancel
-
- {
- this.state.password == '' ? Alert.alert('', i18n.t('Profile.unlockPassword')) : this.ok()
- }}
- >
- ok
-
-
-
-
-
- {/* Please save your information */}
-
-
-
- {i18n.t('Profile.saveInformation')}
-
- {this.state.msg}
-
- {/* */}
-
-
- {i18n.t('TAB.Continue')}
-
-
- {i18n.t('TAB.Copy')}
-
-
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- backgroundColor: '#776f71',
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- title1: {
- height: ScreenHeight / 9,
- backgroundColor: '#776f71',
- flexDirection: 'row',
- alignItems: 'flex-end'
- },
- title2: {
- height: ScreenHeight / 10.6 / 1.6,
- flex: 1,
- justifyContent: 'flex-end',
- alignItems: 'center'
- },
- titletext: {
- marginBottom: ScreenHeight / 50,
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: 'white'
- },
- head: {
- marginTop: ScreenHeight / 55,
- width: ScreenWidth,
- height: ScreenHeight / 3.81 / 2.5,
- alignItems: 'center',
- justifyContent: 'center'
- },
- image: {
- marginTop: ScreenHeight / 30,
- backgroundColor: 'white',
- borderRadius: ScreenHeight / 28,
- height: ScreenHeight / 14,
- width: ScreenHeight / 14,
- resizeMode: 'contain'
- },
- adderss: {
- marginTop: ScreenHeight / 50,
- height: ScreenHeight / 3.81 / 6,
- width: ScreenWidth,
- alignItems: 'center',
- justifyContent: 'center'
- },
- export: {
- width: ScreenWidth - 40,
- backgroundColor: 'white',
- marginBottom: 12,
- flexDirection: 'row',
- alignItems: 'center',
- height: 68,
- borderRadius: 6
- },
- delete: {
- height: 49,
- width: ScreenWidth,
- alignItems: 'center',
- justifyContent: 'center',
- backgroundColor: '#FFFFFF'
- },
- next: {
- marginRight: ScreenWidth / 28
- },
- modal: {
- flex: 1,
- alignItems: 'center',
- justifyContent: 'center',
- backgroundColor: '#00000066'
- },
- chooseview: {
- alignItems: 'center',
- // height: ScreenHeight / 4,
- width: 300,
- backgroundColor: 'white',
- justifyContent: 'center',
- borderRadius: 16
- },
- prompt: {
- marginTop: ScreenHeight / 35,
- fontSize: ScreenWidth / 25,
- fontWeight: '500',
- color: 'black',
- padding: 10
- },
- textInputStyle: {
- height: 49,
- width: 260,
- borderWidth: 1,
- fontSize: 14,
- borderRadius: 2,
- marginVertical: 20
- },
- choose: {
- height: 49,
- width: 150,
- justifyContent: 'center',
- alignItems: 'center'
- },
- yorn: {
- borderTopWidth: 1,
- borderColor: '#ECE2E5',
- alignItems: 'center',
- height: 49,
- flexDirection: 'row'
- },
- textchoose: {
- fontSize: 16,
- color: '#222222'
- }
-})
-export default ManageAccount
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ Alert,
+ Modal,
+ TextInput,
+ Clipboard,
+ Platform,
+ StatusBar,
+ SafeAreaView,
+ InteractionManager
+} from 'react-native'
+import Identicon from 'polkadot-identicon-react-native'
+import SInfo from 'react-native-sensitive-info'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, checkPwd, doubleClick } from '../../../util/Common'
+import Header from '../../../components/Header'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class ManageAccount extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ password: '',
+ address: this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address,
+ isModal1: false,
+ isModal2: false,
+ msg: ''
+ }
+ this.ExportKey = this.ExportKey.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.cancel = this.cancel.bind(this)
+ this.delete_account = this.delete_account.bind(this)
+ this.Continue = this.Continue.bind(this)
+ this.Copy = this.Copy.bind(this)
+ this.Change_Password = this.Change_Password.bind(this)
+ this.Change_Name = this.Change_Name.bind(this)
+ }
+
+ /**
+ * @description 切换到更改账户|Switch to Change_Name page
+ */
+ Change_Name() {
+ this.props.navigation.navigate('Change_Name')
+ }
+
+ /**
+ * @description 切换到更改密码|Switch to Change_Password page
+ */
+ Change_Password() {
+ this.props.navigation.navigate('Change_Password')
+ }
+
+ /**
+ * @description 导出 key store|Export key store
+ */
+ ExportKey() {
+ this.setState({
+ isModal1: true
+ })
+ }
+
+ /**
+ * @description 密码修改|Change password
+ * @param {String} changepassword 密码|password
+ */
+ onChangepassword(changepassword) {
+ this.setState({
+ password: changepassword
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ cancel() {
+ this.setState({
+ password: '',
+ isModal1: false
+ })
+ }
+
+ /**
+ * @description 点击提交|Submit
+ */
+ ok() {
+ checkPwd({
+ address: this.state.address,
+ password: this.state.password,
+ success: () => {
+ this.setState({
+ isModal1: false,
+ isModal2: true
+ })
+ }
+ })
+ }
+
+ /**
+ * @description 点击继续|Click the continue
+ */
+ Continue() {
+ this.setState({
+ password: '',
+ isModal2: false
+ })
+ }
+
+ /**
+ * @description 复制|Click the copy
+ */
+ async Copy() {
+ Clipboard.setString(this.state.msg)
+ Alert.alert('', i18n.t('TAB.CopySuccess'))
+ }
+
+ /**
+ * @description 删除账户|Delete account
+ */
+ delete_account() {
+ Alert.alert(
+ '',
+ i18n.t('Profile.deleteTip'),
+ [
+ {
+ text: 'Cancel',
+ onPress: () => {},
+ style: 'cancel'
+ },
+ {
+ text: 'OK',
+ onPress: () => {
+ SInfo.deleteItem(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address,
+ {
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ }
+ ).then(
+ Alert.alert(
+ '',
+ i18n.t('Profile.DeleteSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ this.props.rootStore.stateStore.Account = 1
+ SInfo.getAllItems({
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ }).then(result => {
+ if (JSON.stringify(result).length < 10) {
+ this.props.rootStore.stateStore.Account = 0
+ this.props.rootStore.stateStore.Accountnum = 0
+ this.props.rootStore.stateStore.Accounts = [
+ {
+ account: 'NeedCreate',
+ address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
+ }
+ ]
+ this.props.navigation.navigate('Create_Account')
+ } else {
+ this.props.rootStore.stateStore.Account = 0
+ this.props.rootStore.stateStore.Accountnum = 0
+ this.props.rootStore.stateStore.Accounts = [
+ {
+ account: 'NeedCreate',
+ address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
+ }
+ ]
+
+ if (Platform.OS == 'android') {
+ // android
+ for (let o in result) {
+ this.props.rootStore.stateStore.Accounts.push({
+ account: JSON.parse(result[o]).meta.name,
+ address: JSON.parse(result[o]).address
+ })
+ this.props.rootStore.stateStore.Account++
+ this.props.rootStore.stateStore.Accountnum++
+ }
+ } else {
+ // ios
+ result.map((item, index) => {
+ item.map((item, index) => {
+ // 添加用户到 mobx
+ // Add account to mobx
+ this.props.rootStore.stateStore.Accounts.push({
+ account: JSON.parse(item.value).meta.name,
+ address: item.key
+ })
+ this.props.rootStore.stateStore.Account = 1
+ this.props.rootStore.stateStore.Accountnum++
+ })
+ })
+ }
+ this.props.rootStore.stateStore.balances.map((item, index) => {
+ if (
+ item.address ==
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ ) {
+ this.props.rootStore.stateStore.balanceIndex = index
+ }
+ })
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ )
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ SInfo.getItem(this.state.address, {
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ }).then(result => {
+ this.setState({
+ msg: result
+ })
+ })
+ })
+ }
+
+ render() {
+ return (
+
+
+
+ {/* The title */}
+
+
+
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+
+
+ {/* Change Name */}
+
+
+ {i18n.t('Profile.ChangeName')}
+
+
+
+
+ {/* Change password */}
+
+
+ {i18n.t('Profile.ChangePassword')}
+
+
+
+
+ {/* Export Keystore */}
+
+ {
+ doubleClick(this.ExportKey)
+ }}
+ >
+ {i18n.t('Profile.ExportKeystore')}
+
+
+
+
+
+ {/* delete account */}
+
+
+
+ {i18n.t('Profile.DeleteAccount')}
+
+
+
+ {/* Please enter your password */}
+
+
+
+ {i18n.t('Profile.unlockPassword')}
+
+ {/* */}
+
+
+ cancel
+
+ {
+ this.state.password == ''
+ ? Alert.alert('', i18n.t('Profile.unlockPassword'))
+ : doubleClick(this.ok())
+ }}
+ >
+ ok
+
+
+
+
+
+ {/* Please save your information */}
+
+
+
+ {i18n.t('Profile.saveInformation')}
+
+ {this.state.msg}
+
+ {/* */}
+
+
+ {i18n.t('TAB.Continue')}
+
+
+ {i18n.t('TAB.Copy')}
+
+
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ backgroundColor: '#776f71',
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ title1: {
+ height: ScreenHeight / 9,
+ backgroundColor: '#776f71',
+ flexDirection: 'row',
+ alignItems: 'flex-end'
+ },
+ title2: {
+ height: ScreenHeight / 10.6 / 1.6,
+ flex: 1,
+ justifyContent: 'flex-end',
+ alignItems: 'center'
+ },
+ titletext: {
+ marginBottom: ScreenHeight / 50,
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: 'white'
+ },
+ head: {
+ marginTop: ScreenHeight / 55,
+ width: ScreenWidth,
+ height: ScreenHeight / 3.81 / 2.5,
+ alignItems: 'center',
+ justifyContent: 'center'
+ },
+ image: {
+ marginTop: ScreenHeight / 30,
+ backgroundColor: 'white',
+ borderRadius: ScreenHeight / 28,
+ height: ScreenHeight / 14,
+ width: ScreenHeight / 14,
+ resizeMode: 'contain'
+ },
+ adderss: {
+ marginTop: ScreenHeight / 50,
+ height: ScreenHeight / 3.81 / 6,
+ width: ScreenWidth,
+ alignItems: 'center',
+ justifyContent: 'center'
+ },
+ export: {
+ width: ScreenWidth - 40,
+ backgroundColor: 'white',
+ marginBottom: 12,
+ flexDirection: 'row',
+ alignItems: 'center',
+ height: 68,
+ borderRadius: 6
+ },
+ delete: {
+ height: 49,
+ width: ScreenWidth,
+ alignItems: 'center',
+ justifyContent: 'center',
+ backgroundColor: '#FFFFFF'
+ },
+ next: {
+ marginRight: ScreenWidth / 28
+ },
+ modal: {
+ flex: 1,
+ alignItems: 'center',
+ justifyContent: 'center',
+ backgroundColor: '#00000066'
+ },
+ chooseview: {
+ alignItems: 'center',
+ // height: ScreenHeight / 4,
+ width: ScreenWidth * 0.7,
+ backgroundColor: 'white',
+ justifyContent: 'center',
+ borderRadius: 16
+ },
+ prompt: {
+ marginTop: ScreenHeight / 35,
+ fontSize: ScreenWidth / 25,
+ fontWeight: '500',
+ color: 'black',
+ padding: 10
+ },
+ textInputStyle: {
+ height: 49,
+ width: 260,
+ borderWidth: 1,
+ fontSize: 14,
+ borderRadius: 2,
+ marginVertical: 20
+ },
+ choose: {
+ height: 49,
+ width: (ScreenWidth * 0.7) / 2,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ yorn: {
+ borderTopWidth: 1,
+ borderColor: '#ECE2E5',
+ alignItems: 'center',
+ height: 49,
+ flexDirection: 'row'
+ },
+ textchoose: {
+ fontSize: 16,
+ color: '#222222'
+ }
+})
+export default ManageAccount
diff --git a/src/page/Profile/secondary/Settings.js b/src/page/Profile/secondary/Settings.js
index 4206a615..6a8250ea 100755
--- a/src/page/Profile/secondary/Settings.js
+++ b/src/page/Profile/secondary/Settings.js
@@ -1,289 +1,308 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-21 22:01:34
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- AsyncStorage,
- Switch,
- Alert,
- Linking,
- Platform,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { checkUpdate, downloadUpdate, switchVersion, switchVersionLater } from 'react-native-update'
-import { NavigationActions, StackActions } from 'react-navigation'
-import { observer, inject } from 'mobx-react'
-import _updateConfig from '../../../../update.json'
-import { ScreenWidth, ScreenHeight } from '../../../util/Common'
-import Header from '../../../components/Header.js'
-import i18n from '../../../locales/i18n'
-import DataRepository from '../../../util/DataRepository'
-
-const { appKey } = _updateConfig[Platform.OS]
-
-@inject('rootStore')
-@observer
-class Settings extends Component {
- constructor(props) {
- super(props)
- this.state = {
- Gesture: this.props.rootStore.stateStore.GestureState == 0 ? false : true
- }
- this.back = this.back.bind(this)
- this.Set_Node = this.Set_Node.bind(this)
- this.Gesture = this.Gesture.bind(this)
- this.Check_Update = this.Check_Update.bind(this)
- }
-
- // 返回
- // Click back
- back() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 切换到设置节点页面
- // Switch to Set_Node page
- Set_Node() {
- this.props.navigation.navigate('Set_Node')
- }
-
- // 更新APP
- // Update App
- doUpdate = info => {
- downloadUpdate(info)
- .then(hash => {
- Alert.alert('', i18n.t('Profile.restartApp'), [
- {
- text: 'Yes',
- onPress: () => {
- switchVersion(hash)
- }
- },
- { text: 'No' },
- {
- text: 'Next startup time',
- onPress: () => {
- switchVersionLater(hash)
- }
- }
- ])
- })
- .catch(() => {
- Alert.alert('', i18n.t('Profile.UpdateFailed'))
- })
- }
-
- // 检查是否有更新
- // Check Update of App
- Check_Update() {
- checkUpdate(appKey)
- .then(info => {
- if (info.expired) {
- Alert.alert('', i18n.t('Profile.toAppStore'), [
- { test: 'No' },
- {
- text: 'Yes',
- onPress: () => {
- Linking.openURL('https://polkawallet.io/#download')
- }
- }
- ])
- } else if (info.upToDate) {
- Alert.alert('', i18n.t('Profile.appV'))
- } else {
- Alert.alert(
- '',
- i18n.t('Profile.checkNewV') + info.name + ',' + i18n.t('Profile.download') + '\n' + info.description,
- [
- {
- text: 'Yes',
- onPress: () => {
- this.doUpdate(info)
- }
- },
- { text: 'No' }
- ]
- )
- }
- })
- .catch(() => {
- Alert.alert('', i18n.t('Profile.UpdateFailed'))
- })
- }
-
- // 设置手势密码
- // Set gesture password
- Gesture(e) {
- this.setState({ Gesture: e })
- if (e) {
- let resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Gesture' })]
- })
- this.props.navigation.dispatch(resetAction)
- } else {
- Alert.alert(
- '',
- i18n.t('Profile.deleteGP'),
- [
- {
- text: 'Cancel',
- onPress: () => {
- this.setState({ Gesture: true })
- },
- style: 'cancel'
- },
- {
- text: 'Confirm',
- onPress: () => {
- this.props.rootStore.stateStore.GestureState = 0
- AsyncStorage.removeItem('Gesture').then(Alert.alert('', i18n.t('Profile.gestureCanceled')))
- }
- }
- ],
- { cancelable: false }
- )
- }
- }
-
- changeLanguage() {
- Alert.alert(
- '',
- i18n.t('TAB.ChangeLanguages'),
- [
- {
- text: 'English',
- onPress: () => {
- i18n.locale = 'en'
- this.setState({
- localLanguage: 'en'
- })
- new DataRepository().saveLocalRepository('localLanguage', 'en')
- },
- style: 'cancel'
- },
- {
- text: '简体中文',
- onPress: () => {
- i18n.locale = 'zh'
- this.setState({
- localLanguage: 'zh'
- })
- new DataRepository().saveLocalRepository('localLanguage', 'zh')
- }
- }
- ],
- { cancelable: true }
- )
- }
-
- render() {
- const msg = [i18n.t('Profile.RemoteNode'), i18n.t('Profile.CheckUpdate')]
- return (
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
- {msg.map((item, index) => {
- return (
- {
- if (index == 0) {
- this.Set_Node()
- }
- if (index == 1) {
- this.Check_Update()
- }
- }}
- >
- {item}
-
-
-
- )
- })}
-
- {i18n.t('TAB.ChangeLanguages')}
-
-
-
-
- {/* Gesture */}
-
- {i18n.t('Profile.Gesture')}
-
- this.Gesture(e)} // 当状态值发生变化值回调 | Callbacks when state values change
- />
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- height: ScreenHeight / 33.35,
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- msgView: {
- backgroundColor: 'white',
- flexDirection: 'row',
- alignItems: 'center',
- height: 56,
- borderWidth: 0.5,
- borderColor: '#ECE2E5',
- marginHorizontal: 1,
- paddingLeft: ScreenWidth * 0.05
- },
- msgText: {
- fontSize: 18,
- color: '#3E2D32'
- },
- msgImage: {
- marginRight: ScreenWidth / 28,
- height: ScreenHeight / 60,
- width: ScreenHeight / 60 / 1.83,
- resizeMode: 'contain'
- }
-})
-export default Settings
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ AsyncStorage,
+ Switch,
+ Alert,
+ Linking,
+ Platform,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { checkUpdate, downloadUpdate, switchVersion, switchVersionLater } from 'react-native-update'
+import { NavigationActions, StackActions } from 'react-navigation'
+import { observer, inject } from 'mobx-react'
+import _updateConfig from '../../../../update.json'
+import { ScreenWidth, ScreenHeight, doubleClick } from '../../../util/Common'
+import Header from '../../../components/Header.js'
+import i18n from '../../../locales/i18n'
+import DataRepository from '../../../util/DataRepository'
+
+const { appKey } = _updateConfig[Platform.OS]
+
+@inject('rootStore')
+@observer
+class Settings extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ Gesture: this.props.rootStore.stateStore.GestureState == 0 ? false : true
+ }
+ this.back = this.back.bind(this)
+ this.Set_Node = this.Set_Node.bind(this)
+ this.Gesture = this.Gesture.bind(this)
+ this.Check_Update = this.Check_Update.bind(this)
+ }
+
+ /**
+ * @description 返回|Click back
+ */
+ back() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 切换到设置节点页面|Switch to Set_Node page
+ */
+ Set_Node() {
+ this.props.navigation.navigate('Set_Node')
+ }
+
+ /**
+ * @description 更新APP|Update App
+ */
+ doUpdate = info => {
+ downloadUpdate(info)
+ .then(hash => {
+ Alert.alert('', i18n.t('Profile.restartApp'), [
+ {
+ text: 'Yes',
+ onPress: () => {
+ switchVersion(hash)
+ }
+ },
+ { text: 'No' },
+ {
+ text: 'Next startup time',
+ onPress: () => {
+ switchVersionLater(hash)
+ }
+ }
+ ])
+ })
+ .catch(() => {
+ Alert.alert('', i18n.t('Profile.UpdateFailed'))
+ })
+ }
+
+ /**
+ * @description 检查是否有更新|Check Update of App
+ */
+ Check_Update() {
+ checkUpdate(appKey)
+ .then(info => {
+ if (info.expired) {
+ Alert.alert('', i18n.t('Profile.toAppStore'), [
+ {
+ test: 'No',
+ style: 'cancel'
+ },
+ {
+ text: 'Yes',
+ onPress: () => {
+ Linking.openURL('https://polkawallet.io/#download')
+ }
+ }
+ ])
+ } else if (info.upToDate) {
+ Alert.alert('', i18n.t('Profile.appV'))
+ } else {
+ Alert.alert(
+ '',
+ i18n.t('Profile.checkNewV') + info.name + ',' + i18n.t('Profile.download') + '\n' + info.description,
+ [
+ {
+ text: 'Yes',
+ onPress: () => {
+ this.doUpdate(info)
+ }
+ },
+ { text: 'No' }
+ ]
+ )
+ }
+ })
+ .catch(() => {
+ Alert.alert('', i18n.t('Profile.UpdateFailed'))
+ })
+ }
+
+ /**
+ * @description 设置手势密码|Set gesture password
+ * @param {*} e
+ */
+ Gesture(e) {
+ this.setState({ Gesture: e })
+ if (e) {
+ let resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Gesture' })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ } else {
+ Alert.alert(
+ '',
+ i18n.t('Profile.deleteGP'),
+ [
+ {
+ text: 'Cancel',
+ onPress: () => {
+ this.setState({ Gesture: true })
+ },
+ style: 'cancel'
+ },
+ {
+ text: 'Confirm',
+ onPress: () => {
+ this.props.rootStore.stateStore.GestureState = 0
+ AsyncStorage.removeItem('Gesture').then(Alert.alert('', i18n.t('Profile.gestureCanceled')))
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }
+
+ /**
+ * @description 更换语言|Change language
+ */
+ changeLanguage() {
+ Alert.alert(
+ '',
+ i18n.t('TAB.ChangeLanguages'),
+ [
+ {
+ text: 'English',
+ onPress: () => {
+ i18n.locale = 'en'
+ this.setState({
+ localLanguage: 'en'
+ })
+ new DataRepository().saveLocalRepository('localLanguage', 'en')
+ },
+ style: 'cancel'
+ },
+ {
+ text: '简体中文',
+ onPress: () => {
+ i18n.locale = 'zh'
+ this.setState({
+ localLanguage: 'zh'
+ })
+ new DataRepository().saveLocalRepository('localLanguage', 'zh')
+ }
+ }
+ ],
+ { cancelable: true }
+ )
+ }
+
+ render() {
+ const msg = [i18n.t('Profile.RemoteNode'), i18n.t('Profile.CheckUpdate')]
+ return (
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+ {msg.map((item, index) => {
+ return (
+ {
+ if (index == 0) {
+ this.Set_Node()
+ }
+ if (index == 1) {
+ doubleClick(this.Check_Update())
+ }
+ }}
+ >
+ {item}
+
+
+
+ )
+ })}
+ {
+ doubleClick(this.changeLanguage.bind(this))
+ }}
+ >
+ {i18n.t('TAB.ChangeLanguages')}
+
+
+
+
+ {/* Gesture */}
+
+ {i18n.t('Profile.Gesture')}
+
+ this.Gesture(e)} // 当状态值发生变化值回调 | Callbacks when state values change
+ />
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ height: ScreenHeight / 33.35,
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ msgView: {
+ backgroundColor: 'white',
+ flexDirection: 'row',
+ alignItems: 'center',
+ height: 56,
+ borderWidth: 0.5,
+ borderColor: '#ECE2E5',
+ marginHorizontal: 1,
+ paddingLeft: ScreenWidth * 0.05
+ },
+ msgText: {
+ fontSize: 18,
+ color: '#3E2D32'
+ },
+ msgImage: {
+ marginRight: ScreenWidth / 28,
+ height: ScreenHeight / 60,
+ width: ScreenHeight / 60 / 1.83,
+ resizeMode: 'contain'
+ }
+})
+export default Settings
diff --git a/src/page/Profile/secondary/Settings/Gesture.js b/src/page/Profile/secondary/Settings/Gesture.js
index 2fa25c47..f36766fb 100755
--- a/src/page/Profile/secondary/Settings/Gesture.js
+++ b/src/page/Profile/secondary/Settings/Gesture.js
@@ -1,149 +1,159 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { AsyncStorage, SafeAreaView, StatusBar, View } from 'react-native'
-import { NavigationActions, StackActions } from 'react-navigation'
-import PasswordGesture from 'react-native-gesture-password'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth } from '../../../../util/Common'
-import i18n from '../../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Gesture extends Component {
- constructor(props) {
- super(props)
- this.state = {
- status: 'right',
- message: this.props.rootStore.stateStore.GestureState == 0 ? 'Please set the gesture password' : 'Password'
- }
- this.onStart = this.onStart.bind(this)
- this.onEnd = this.onEnd.bind(this)
- }
-
- onEnd(password) {
- // 第一次设置密码
- // First time to set the gesture password
- if (this.props.rootStore.stateStore.GestureState == 0) {
- this.props.rootStore.stateStore.GestureState = 1
- this.props.rootStore.stateStore.Gesture = password
- this.setState({
- status: 'right',
- message: i18n.t('Profile.confirmGesture')
- })
- } else {
- // 确认上一次输入密码
- // Confirm the gesture password
- if (this.props.rootStore.stateStore.GestureState == 1) {
- // 确认成功
- // Confirm success
- if (password == this.props.rootStore.stateStore.Gesture) {
- this.props.rootStore.stateStore.GestureState = 2
- this.props.rootStore.stateStore.Gesture = password
- AsyncStorage.setItem('Gesture', password)
- this.setState({
- status: 'right',
- message: i18n.t('Profile.gestureSuccess')
- })
- setTimeout(() => {
- let resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Settings' })]
- })
- this.props.navigation.dispatch(resetAction)
- }, 500)
- } else {
- // 确认失败
- // Confirm faild
- this.props.rootStore.stateStore.GestureState = 0
- this.setState({
- status: 'wrong',
- message: i18n.t('Profile.gestureFailed')
- })
- }
- } else {
- // 验证密码
- // Verify gesture password
- if (this.props.rootStore.stateStore.GestureState == 2) {
- if (password == this.props.rootStore.stateStore.Gesture) {
- this.setState({
- status: 'right',
- message: i18n.t('TAB.PasswordCorrect')
- })
- setTimeout(() => {
- let resetAction = StackActions.reset({
- index: 0,
- actions: [NavigationActions.navigate({ routeName: 'Tabbed_Navigation' })]
- })
- this.props.navigation.dispatch(resetAction)
- }, 500)
- } else {
- this.setState({
- status: 'wrong',
- message: i18n.t('TAB.PasswordMistake')
- })
- }
- }
- }
- }
- }
-
- onStart() {
- this.setState({
- status: 'normal',
- message: i18n.t('Profile.inputPWD')
- })
- }
-
- onReset() {
- this.setState({
- status: 'normal',
- message: i18n.t('Profile.inputPWD_d')
- })
- }
-
- render() {
- return (
-
-
-
- this.onStart()}
- onEnd={password => this.onEnd(password)}
- />
-
-
- )
- }
-}
-export default Gesture
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { AsyncStorage, SafeAreaView, StatusBar, View } from 'react-native'
+import { NavigationActions, StackActions } from 'react-navigation'
+import PasswordGesture from 'react-native-gesture-password'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth } from '../../../../util/Common'
+import i18n from '../../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Gesture extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ status: 'right',
+ message: this.props.rootStore.stateStore.GestureState == 0 ? 'Please set the gesture password' : 'Password'
+ }
+ this.onStart = this.onStart.bind(this)
+ this.onEnd = this.onEnd.bind(this)
+ }
+
+ /**
+ * @description 滑动结束|End of the slide
+ * @param {String} password 密码|password
+ */
+ onEnd(password) {
+ // 第一次设置密码
+ // First time to set the gesture password
+ if (this.props.rootStore.stateStore.GestureState == 0) {
+ this.props.rootStore.stateStore.GestureState = 1
+ this.props.rootStore.stateStore.Gesture = password
+ this.setState({
+ status: 'right',
+ message: i18n.t('Profile.confirmGesture')
+ })
+ } else {
+ // 确认上一次输入密码
+ // Confirm the gesture password
+ if (this.props.rootStore.stateStore.GestureState == 1) {
+ // 确认成功
+ // Confirm success
+ if (password == this.props.rootStore.stateStore.Gesture) {
+ this.props.rootStore.stateStore.GestureState = 2
+ this.props.rootStore.stateStore.Gesture = password
+ AsyncStorage.setItem('Gesture', password)
+ this.setState({
+ status: 'right',
+ message: i18n.t('Profile.gestureSuccess')
+ })
+ setTimeout(() => {
+ let resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Settings' })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ }, 500)
+ } else {
+ // 确认失败
+ // Confirm faild
+ this.props.rootStore.stateStore.GestureState = 0
+ this.setState({
+ status: 'wrong',
+ message: i18n.t('Profile.gestureFailed')
+ })
+ }
+ } else {
+ // 验证密码
+ // Verify gesture password
+ if (this.props.rootStore.stateStore.GestureState == 2) {
+ if (password == this.props.rootStore.stateStore.Gesture) {
+ this.setState({
+ status: 'right',
+ message: i18n.t('TAB.PasswordCorrect')
+ })
+ setTimeout(() => {
+ let resetAction = StackActions.reset({
+ index: 0,
+ actions: [NavigationActions.navigate({ routeName: 'Tabbed_Navigation' })]
+ })
+ this.props.navigation.dispatch(resetAction)
+ }, 500)
+ } else {
+ this.setState({
+ status: 'wrong',
+ message: i18n.t('TAB.PasswordMistake')
+ })
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @description 开始滑动|Start to slide
+ */
+ onStart() {
+ this.setState({
+ status: 'normal',
+ message: i18n.t('Profile.inputPWD')
+ })
+ }
+
+ /**
+ * @description 重置密码|Reset password
+ */
+ onReset() {
+ this.setState({
+ status: 'normal',
+ message: i18n.t('Profile.inputPWD_d')
+ })
+ }
+
+ render() {
+ return (
+
+
+
+ this.onStart()}
+ onEnd={password => this.onEnd(password)}
+ />
+
+
+ )
+ }
+}
+export default Gesture
diff --git a/src/page/Profile/secondary/Settings/SetNode.js b/src/page/Profile/secondary/Settings/SetNode.js
index 7767e2bc..7e20aaa5 100755
--- a/src/page/Profile/secondary/Settings/SetNode.js
+++ b/src/page/Profile/secondary/Settings/SetNode.js
@@ -1,261 +1,283 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-22 00:21:58
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- TextInput,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import Api from '@polkadot/api/promise'
-import WsProvider from '@polkadot/rpc-provider/ws'
-import { ScreenWidth, ScreenHeight } from '../../../../util/Common'
-import Header from '../../../../components/Header'
-import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
-import i18n from '../../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class SetNode extends Component {
- constructor(props) {
- super(props)
- this.state = {
- node: '',
- chooseNode: 'ws://45.32.115.98:9944/',
- isCustom: false
- }
- this.back = this.back.bind(this)
- this.onChangeNode = this.onChangeNode.bind(this)
- this.Set_Node = this.Set_Node.bind(this)
- this.chooseNode = this.chooseNode.bind(this)
- this.Noclick = this.Noclick.bind(this)
- }
-
- back() {
- this.props.navigation.navigate('Settings')
- }
-
- onChangeNode(onChangeNode) {
- this.setState({
- node: onChangeNode
- })
- }
-
- Noclick() {
- return null
- }
-
- chooseNode() {
- Alert.alert(
- '',
- i18n.t('Profile.SelectNode'),
- [
- {
- text: 'wss://poc3-rpc.polkadot.io/',
- onPress: () => {
- this.setState({ chooseNode: 'wss://poc3-rpc.polkadot.io/' })
- },
- style: 'cancel'
- },
- {
- text: 'ws://45.32.115.98:9944/',
- onPress: () => {
- this.setState({ chooseNode: 'ws://45.32.115.98:9944/' })
- },
- style: 'cancel'
- },
- {
- text: i18n.t('Profile.Custom'),
- onPress: () => {
- this.setState({ isCustom: true })
- },
- style: 'cancel'
- },
- { text: 'cancel', onPress: () => {}, style: 'cancel' }
- ],
- { cancelable: true }
- )
- }
-
- Set_Node() {
- Alert.alert(
- '',
- i18n.t('Profile.changeNode') + '"' + this.state.chooseNode + '"',
- [
- { text: i18n.t('Profile.Cancel'), onPress: () => {}, style: 'cancel' },
- {
- text: i18n.t('Profile.Confirm'),
- onPress: () => {
- ;(async () => {
- this.props.rootStore.stateStore.ENDPOINT = this.state.chooseNode
- const provider = new WsProvider(this.state.chooseNode)
- const api = await Api.create(provider)
- this.props.rootStore.stateStore.API = api
- this.props.navigation.navigate('Tabbed_Navigation')
- })()
- }
- }
- ],
- { cancelable: false }
- )
- }
-
- componentWillMount() {
- this.setState({ chooseNode: this.props.rootStore.stateStore.ENDPOINT })
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
- {i18n.t('Profile.NOTETip_1')}
-
-
-
-
-
-
-
- {i18n.t('Profile.NOTETip_2')}
- {this.state.isCustom ? (
-
- {i18n.t('Profile.enterNode')}
-
-
- ) : (
-
- )}
-
-
- {
- this.state.isCustom ? this.setState({ chooseNode: this.state.node, isCustom: false }) : this.Set_Node()
- }}
- >
-
- {i18n.t('Profile.SetNode')}
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- image_title: {
- width: ScreenHeight / 33.35,
- resizeMode: 'contain'
- },
- text: {
- marginTop: ScreenHeight / 20,
- width: ScreenWidth - 40,
- fontSize: ScreenWidth / 24,
- color: '#696969'
- },
- textInputStyle: {
- paddingVertical: 0,
- marginTop: ScreenHeight / 70,
- height: 40,
- width: ScreenWidth - 40,
- borderWidth: 1,
- borderColor: '#DCDCDC',
- fontSize: ScreenWidth / 25,
- borderRadius: ScreenHeight / 150,
- paddingHorizontal: 20
- },
- Touch: {
- height: 48,
- width: ScreenWidth - 40,
- borderRadius: 8,
- backgroundColor: '#FF4081C7',
- alignSelf: 'center',
- marginBottom: 40,
- alignItems: 'center',
- justifyContent: 'center'
- }
-})
-export default SetNode
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ Image,
+ TouchableOpacity,
+ TextInput,
+ Alert,
+ StatusBar,
+ SafeAreaView,
+ InteractionManager
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import Api from '@polkadot/api/promise'
+import WsProvider from '@polkadot/rpc-provider/ws'
+import { ScreenWidth, ScreenHeight } from '../../../../util/Common'
+import Header from '../../../../components/Header'
+import RNKeyboardAvoidView from '../../../../components/RNKeyboardAvoidView'
+import i18n from '../../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class SetNode extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ node: '',
+ chooseNode: 'ws://45.32.115.98:9944/',
+ isCustom: false
+ }
+ this.back = this.back.bind(this)
+ this.onChangeNode = this.onChangeNode.bind(this)
+ this.Set_Node = this.Set_Node.bind(this)
+ this.chooseNode = this.chooseNode.bind(this)
+ this.Noclick = this.Noclick.bind(this)
+ }
+
+ /**
+ * @description 返回|Click the back
+ */
+ back() {
+ this.props.navigation.navigate('Settings')
+ }
+
+ /**
+ * @description 更换节点|Change the node
+ * @param {String} onChangeNode 节点|Node
+ */
+ onChangeNode(onChangeNode) {
+ this.setState({
+ node: onChangeNode
+ })
+ }
+
+ /**
+ * @description 空点击|Click on the empty
+ */
+ Noclick() {
+ return null
+ }
+
+ /**
+ * @description 选择更换的节点|Select the replaced node
+ */
+ chooseNode() {
+ Alert.alert(
+ '',
+ i18n.t('Profile.SelectNode'),
+ [
+ {
+ text: 'wss://poc3-rpc.polkadot.io/',
+ onPress: () => {
+ this.setState({ chooseNode: 'wss://poc3-rpc.polkadot.io/' })
+ },
+ style: 'cancel'
+ },
+ {
+ text: 'ws://45.32.115.98:9944/',
+ onPress: () => {
+ this.setState({ chooseNode: 'ws://45.32.115.98:9944/' })
+ },
+ style: 'cancel'
+ },
+ {
+ text: i18n.t('Profile.Custom'),
+ onPress: () => {
+ this.setState({ isCustom: true })
+ },
+ style: 'cancel'
+ },
+ { text: 'cancel', onPress: () => {}, style: 'cancel' }
+ ],
+ { cancelable: true }
+ )
+ }
+
+ /**
+ * @description 设置节点|Set node
+ */
+ Set_Node() {
+ Alert.alert(
+ '',
+ i18n.t('Profile.changeNode') + '"' + this.state.chooseNode + '"',
+ [
+ { text: i18n.t('Profile.Cancel'), onPress: () => {}, style: 'cancel' },
+ {
+ text: i18n.t('Profile.Confirm'),
+ onPress: () => {
+ ;(async () => {
+ this.props.rootStore.stateStore.ENDPOINT = this.state.chooseNode
+ const provider = new WsProvider(this.state.chooseNode)
+ const api = await Api.create(provider)
+ this.props.rootStore.stateStore.API = api
+ this.props.navigation.navigate('Tabbed_Navigation')
+ })()
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ this.setState({ chooseNode: this.props.rootStore.stateStore.ENDPOINT })
+ })
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+ {i18n.t('Profile.NOTETip_1')}
+
+
+
+
+
+
+
+ {i18n.t('Profile.NOTETip_2')}
+ {this.state.isCustom ? (
+
+ {i18n.t('Profile.enterNode')}
+
+
+ ) : (
+
+ )}
+
+
+ {
+ this.state.isCustom ? this.setState({ chooseNode: this.state.node, isCustom: false }) : this.Set_Node()
+ }}
+ >
+
+ {i18n.t('Profile.SetNode')}
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ image_title: {
+ width: ScreenHeight / 33.35,
+ resizeMode: 'contain'
+ },
+ text: {
+ marginTop: ScreenHeight / 20,
+ width: ScreenWidth - 40,
+ fontSize: ScreenWidth / 24,
+ color: '#696969'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ marginTop: 20,
+ height: 50,
+ width: ScreenWidth - 40,
+ borderWidth: 1,
+ borderColor: '#DCDCDC',
+ fontSize: 18,
+ borderRadius: 5,
+ paddingHorizontal: 20
+ },
+ Touch: {
+ height: 48,
+ width: ScreenWidth - 40,
+ borderRadius: 8,
+ backgroundColor: '#FF4081C7',
+ alignSelf: 'center',
+ marginBottom: 40,
+ alignItems: 'center',
+ justifyContent: 'center'
+ }
+})
+export default SetNode
diff --git a/src/page/Staking/Staking.js b/src/page/Staking/Staking.js
index 6a61c3ba..48130465 100755
--- a/src/page/Staking/Staking.js
+++ b/src/page/Staking/Staking.js
@@ -1,1706 +1,1795 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-19 21:24:18
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- TouchableOpacity,
- ScrollView,
- Image,
- RefreshControl,
- SafeAreaView,
- Platform,
- ImageBackground,
- StatusBar,
- Alert
-} from 'react-native'
-import moment from 'moment/moment'
-import Identicon from 'polkadot-identicon-react-native'
-import { formatBalance } from '@polkadot/util'
-import Echarts from 'native-echarts'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, formatData, axios } from '../../util/Common'
-import polkadotAPI from '../../util/polkadotAPI'
-import i18n from '../../locales/i18n'
-
-const styles = StyleSheet.create({
- navContent: {
- width: ScreenWidth,
- height: 77,
- alignItems: 'center'
- }
-})
-@inject('rootStore')
-@observer
-class Staking extends Component {
- constructor(props) {
- super(props)
- this.state = {
- stashAccountTag: false,
- controllerAccountTag: false,
- curTab: 1, // 当前tab | The current tab
- isrefresh: false, // 隐藏刷新 | Hide the refresh
- isselectJumpPageShow: false,
- validators: [],
- validatorNum: 0,
- validatorCount: 0,
-
- intentions: [],
- intentionNum: 0,
-
- sessionProgress: 0,
- sessionLength: 0,
-
- eraProgress: 0,
- eraLength: 0,
-
- titlebottomSO: 1, // Validators 和 Next up 的tab切换 | Switch Validators and Next up's tab
-
- nextUp: [], // next Up 集合 | collection of next Up
- nextUpBalances: [], // next up 余额集合 | collection of next Up balance
-
- StakingOption: {
- title: {
- text: i18n.t('Staking.stakingOption'),
- textStyle: {
- color: '#3E2D32',
- fontSize: 16
- },
- padding: [0, 0, 0, 0]
- },
- tooltip: {},
- legend: {
- data: ['']
- },
- grid: {
- left: 5
- },
- xAxis: {
- axisLine: {
- show: false
- },
- data: []
- },
- yAxis: {
- axisLine: {
- show: false
- },
- position: 'right'
- },
- color: ['#FF5080'],
- series: [
- {
- type: 'line',
- smooth: true,
- data: []
- }
- ]
- },
-
- AccountMsg: {
- // 默认账户信息
- // Default account information
- available: 0,
- balance: 0,
- bonded: 0,
- lockedes: []
- },
- controllerToStash: {},
- controllersAccount: '', // 控制账户信息 | Control account information
- accountChangeTag: false, // 账户相关的按钮是否可以点击 | Whether the operation buttons can be clicked
- // showBtnType: 0: Not show, 1: Unbond + AddBond, 2: Unbond, 3: Unnominate, 4: Unvalidate, 5: nominate + validate, 6: bond
- showBtnType: 0, // 0 不展示 1.解绑 + 追加绑定 2.解绑 3. 取消提名 4.取消验证 5.提名 + 验证 6.绑定
- titlebottomAA: 1, // Slash Records 、Nominating、MyNominators tab切换的tab值
- staking_list_alexander: [], // Slash Records
- pageNum: 1, // Slash Records 的页数 | Slash Records pages Number
- hasNextPage: false, // Slash Records 是否有下一页 | Is there a next page of Slash Records?
- nominating: [], // nominating 的合集
- nominatingBalance: [], // nominating 所有账户余额的集合
- myNominators: [] // myNominators 的合集
- }
- }
-
- initPage() {
- ;(async () => {
- const _this = this
- // 查询all
- let validatorCount
- let sessionLength
- let eraLength
- ;[validatorCount, sessionLength, eraLength] = await Promise.all([
- polkadotAPI.validatorCount(),
- polkadotAPI.sessionLength(),
- polkadotAPI.eraLength()
- ])
-
- _this.setState({
- validatorCount,
- sessionLength,
- eraLength
- })
- polkadotAPI.sessionProgress(sessionProgress => {
- _this.setState({
- sessionProgress
- })
- })
- polkadotAPI.eraProgress(eraProgress => {
- _this.setState({
- eraProgress
- })
- })
-
- const oldvalidators = await polkadotAPI.validators()
-
- const newValidators = await Promise.all(oldvalidators.map(authorityId => polkadotAPI.accountInfo(authorityId)))
- _this.setState({
- validators: newValidators,
- validatorNum: newValidators.length
- })
-
- await polkadotAPI.controllers(intentions => {
- _this.setState({
- intentions: intentions[0],
- intentionNum: intentions[0].length
- })
- })
- })()
- }
-
- loadAccountActions() {
- ;(async () => {
- this.loadSlashRecords()
- this.getStakingOption(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
- let address = await polkadotAPI.bonded(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- ) // 检测是否为“存储账户(stash)" | The account is stash account?
- address = String(address)
- if (address) {
- // 存储账户(stash)
- this.setState({
- controllerAccountTag: false,
- stashAccountTag: true
- })
- this.setState({
- controllersAccount: String(address),
- accountChangeTag: true
- })
- let AccountMsg = await polkadotAPI.accountInfo(String(address)) // 查对应的控制账户信息 | Check the control account info
- AccountMsg = formatData(AccountMsg).stakingLedger
-
- let allLockedValue = 0 // 所有解绑的值 | All of the unbound values
- const lockedes = [] // 解绑中的每个对象的集合 | Object of Unbond
- let balance = await polkadotAPI.freeBalance(
- String(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
- ) // 余额 | Balance
- const bonded = Number(AccountMsg.active)
- balance = String(Number(balance))
-
- if (AccountMsg.unlocking.length > 0) {
- // 解绑中的数量大于1
- // The number of unbond is greater than 1
- for (let i = 0; i < AccountMsg.unlocking.length; i++) {
- allLockedValue = String(Number(allLockedValue) + Number(AccountMsg.unlocking[i].value))
- lockedes.push({
- value: AccountMsg.unlocking[i].value,
- era: AccountMsg.unlocking[i].era
- })
- }
- }
-
- const available = balance - bonded - allLockedValue
-
- this.setState({
- AccountMsg: {
- available,
- balance,
- bonded,
- lockedes
- }
- })
- if (available == 0) {
- // 显示Unbond 隐藏Bond Additional
- // Show Unbond, hide Bond Additional
- this.setState({
- showBtnType: 2
- })
- } else if (available != 0) {
- // 显示Bond Additional和Unbond 按钮
- // Displays Bond Additional and Unbond buttons
- this.setState({
- showBtnType: 1
- })
- }
- } else {
- // 不是储存账户
- // Not is stash account
- this.setState({
- stashAccountTag: false
- })
- const balance = await polkadotAPI.freeBalance(
- String(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
- )
- const AccountMsg = await polkadotAPI.accountInfo(
- String(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
- ) // 查对应的控制账户信息 | Check the control account info
- this.setState({
- AccountMsg: {
- balance
- }
- })
- let controller = await polkadotAPI.ledger(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- ) // 判断是否为控制账户 | Determine whether it is a control account
- controller = formatData(controller)
- if (controller && controller != null && controller != 'null') {
- // 如果是控制账户
- // Is control account
- this.setState({
- controllerAccountTag: true,
- controllerToStash: {
- address: String(AccountMsg.stakingLedger.stash),
- polkakey: AccountMsg.stakingLedger.active
- }
- })
-
- if (this.state.intentions.length == 0) {
- await polkadotAPI.controllers(intentions => {
- this.setState(
- {
- intentions: formatData(intentions[0]),
- intentionNum: intentions[0].length
- },
- () => {
- if (this.state.intentions.includes(String(controller.stash))) {
- // 验证状态 显示停止验证
- // Validation status, displays stop validate
- this.setState({
- showBtnType: 4
- })
- } else {
- // 判断提名
- // Determine the nomination
- ;(async () => {
- const info = await polkadotAPI.accountInfo(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- )
- const nominating = formatData(info).nominators
- if (nominating.length > 0) {
- // 提名个数大于0 正在提名 显示停止提名
- // When the number of nominators is greater than 0, display stops nominate
- this.setState({
- showBtnType: 3
- })
- } else {
- // 既没有验证 也 没有提名 显示验证和提名
- // Neither validate nor nominate, shows validate and nominate
- this.setState({
- showBtnType: 5
- })
- }
- })()
- }
- }
- )
- })
- } else if (this.state.intentions.includes(controller.stash)) {
- // 验证状态 显示停止验证
- // validate status, displays stop validate
- this.setState({
- showBtnType: 4
- })
- } else {
- // 判断提名
- // Determine the nominate
- const info = await polkadotAPI.accountInfo(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- )
- const nominating = formatData(info).nominators
- if (nominating.length > 0) {
- // 提名个数大于0 正在提名 显示停止提名
- // When the number of nominators is greater than 0, display stops nominate
- this.setState({
- showBtnType: 3
- })
- } else {
- // 既没有验证 也 没有提名 显示验证和提名
- // Neither validate nor nominate, shows validate and nominate
- this.setState({
- showBtnType: 5
- })
- }
- }
- } else {
- // 显示绑定bond 按钮
- // Show the Bond button
- this.setState({
- controllerAccountTag: false,
- showBtnType: 6
- })
- }
- }
-
- const info = await polkadotAPI.accountInfo(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- )
- const nominating = formatData(info).nominators
- const nominatingBalance = await Promise.all(
- nominating.map(authorityId => polkadotAPI.accountInfo(String(authorityId)))
- )
- this.setState({
- nominating: nominating || [],
- nominatingBalance: nominatingBalance || [],
- myNominators: formatData(info).stakers.others
- })
- })()
- }
-
- // Click account actions
- AccountActions() {
- this.setState({
- curTab: 2
- })
- this.loadAccountActions()
- }
-
- // Load the Slash Records
- loadSlashRecords(pageNum = 1) {
- const _this = this
- const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_list_alexander'
- let params = {
- pageNum,
- pageSize: 10,
- user_address: this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- }
- params = JSON.stringify(params)
- axios(REQUEST_URL, params)
- .then(result => {
- let staking_list_alexander = []
- if (pageNum == 1) {
- staking_list_alexander = result.staking_list_alexander.list
- } else {
- staking_list_alexander = [...this.state.staking_list_alexander, result.staking_list_alexander.list]
- }
- _this.setState({
- hasNextPage: result.staking_list_alexander.hasNextPage,
- staking_list_alexander
- })
- })
- .catch()
- }
-
- // 分页加载 Slash Records
- Loadmore() {
- this.setState(
- {
- pageNum: this.state.pageNum + 1
- },
- () => {
- this.loadSlashRecords(this.state.pageNum)
- }
- )
- }
-
- // 获取当前账户折线图数据
- // Get the current account chart data
- getStakingOption(address) {
- const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_chart_alexander'
- const params = `{"user_address":"${String(address)}","UTCdate":"${moment(new Date().getTime()).format(
- 'YYYY-MM-DD HH:mm:ss'
- )}"}`
- axios(REQUEST_URL, params)
- .then(result => {
- const _StakingOption = {
- title: {
- text: i18n.t('Staking.stakingOption'),
- textStyle: {
- color: '#3E2D32',
- fontSize: 16
- },
- padding: [0, 0, 0, 0]
- },
- tooltip: {},
- legend: {
- data: ['']
- },
- grid: {
- left: 5
- },
- xAxis: {
- axisLine: {
- show: false
- },
- data: []
- },
- yAxis: {
- axisLine: {
- show: false
- },
- position: 'right'
- },
- color: ['#FF5080'],
- series: [
- {
- type: 'line',
- smooth: true,
- data: []
- }
- ]
- }
- result.map(item => {
- _StakingOption.xAxis.data.push(`${item.time.substring(5, 7)}/${item.time.substring(8, 10)}`)
- _StakingOption.series[0].data.push((item.slash_balance / 1000000).toFixed(1))
- })
- let max = 0
- for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
- if (_StakingOption.series[0].data[i] > max) {
- max = _StakingOption.series[0].data[i]
- }
- }
- const power =
- formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).power +
- formatBalance.getDefaults().decimals
- const unit = formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).text
- for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
- _StakingOption.series[0].data[i] = (_StakingOption.series[0].data[i] / Number(Math.pow(10, power))).toFixed(3)
- }
- _StakingOption.title.text = `${i18n.t('Staking.stakingOption_new')} ( ${unit} )`
- this.setState({
- StakingOption: _StakingOption
- })
- })
- .catch()
- }
-
- // 刷新
- refresh(type) {
- this.setState({
- isrefresh: true
- })
- if (type == 1) {
- this.setState(
- {
- validators: [],
- validatorNum: 0,
- validatorCount: 0,
-
- intentions: [],
- intentionNum: 0,
-
- sessionProgress: 0,
- sessionLength: 0,
-
- eraProgress: 0,
- eraLength: 0,
-
- titlebottomSO: 1, // Validators 和 Next up 的tab切换
-
- nextUp: [], // next Up 集合
- nextUpBalances: [] // next up 余额集合
- },
- () => {
- this.setState({
- isrefresh: false
- })
- this.initPage()
- }
- )
- } else if (type == 2) {
- this.setState(
- {
- controllerAccountTag: false,
- stashAccountTag: true,
- StakingOption: {
- title: {
- text: i18n.t('Staking.stakingOption'),
- textStyle: {
- color: 'grey',
- fontSize: 16
- }
- },
-
- tooltip: {
- triggerOn: 'none'
- },
- legend: {
- data: ['']
- },
- xAxis: {
- axisPointer: { handle: { show: true } },
-
- axisLine: {
- show: false
- },
- data: []
- },
- yAxis: {
- axisLine: {
- show: false
- },
- position: 'right'
- },
- color: ['#FF5080'],
- series: [
- {
- type: 'line',
- smooth: true,
- data: []
- }
- ]
- },
- intentions: [],
- intentionNum: 0,
- AccountMsg: {
- // 默认账户信息
- available: 0,
- balance: 0,
- bonded: 0,
- lockedes: []
- },
-
- controllersAccount: '', // 控制账户信息
- accountChangeTag: false, // 账户相关的按钮是否可以点击
- showBtnType: 0, // 0 不展示 1.解绑 + 追加绑定 2.解绑 3. 取消提名 4.取消验证 5.提名 + 验证 6.绑定
- titlebottomAA: 1, // Slash Records 、Nominating、MyNominators tab切换的tab值
- staking_list_alexander: [], // Slash Records
- pageNum: 1, // Slash Records 的页数
- hasNextPage: false, // Slash Records 是否有下一页
- nominating: [], // nominating 的合集
- nominatingBalance: [], // nominating 所有账户余额的集合
- myNominators: [] // myNominators 的合集
- },
- () => {
- this.setState({
- isrefresh: false
- })
- this.AccountActions()
- }
- )
- }
- }
-
- // 跳转个人信息界面
- toValidator_Info(address) {
- this.props.navigation.navigate('Validator_Info', { address: String(address) })
- }
-
- stake() {
- this.props.navigation.navigate('Stake')
- }
-
- Unstake() {
- this.props.navigation.navigate('Unstake')
- }
-
- Unnominate() {
- this.props.navigation.navigate('Unnominate')
- }
-
- nominate() {
- this.props.rootStore.stateStore.tonominate = 0
- this.props.navigation.navigate('Nominate', { address: '' })
- }
-
- BondAdditional() {
- this.props.navigation.navigate('BondAdditional')
- }
-
- selectJumpPage() {
- Alert.alert(
- '',
- i18n.t('Staking.PleaseChoose'),
- [
- {
- text: i18n.t('Staking.Unbond'),
- onPress: () => {
- this.Unbond()
- }
- },
- {
- text: i18n.t('Staking.SetSessionKey'),
- onPress: () => {
- this.setSessionKey()
- }
- },
- {
- text: i18n.t('TAB.Cancel'),
- onPress: () => {
- console.log('Cancel Pressed')
- },
- style: 'cancel'
- }
- ],
- { cancelable: true }
- )
- }
-
- setSessionKey() {
- this.props.navigation.navigate('SetSessionKey')
- }
-
- Unbond() {
- this.props.navigation.navigate('Unbond')
- }
-
- BondFunds() {
- this.props.navigation.navigate('BondFunds')
- }
-
- changeSOIndex() {
- const _this = this
- this.setState({
- titlebottomSO: 2
- })
- if (this.state.nextUp.length == 0 && this.state.validators.length != 0) {
- ;(async () => {
- polkadotAPI.controllers(controllers => {
- const _validators = []
- const _controllers = []
- let _newControllers = []
- this.state.validators.map(item => {
- _validators.push(String(formatData(item).stashId))
- })
- controllers[0].map(item => {
- _controllers.push(String(formatData(item)))
- })
- const a = new Set(_controllers)
- const b = new Set(_validators)
- _newControllers = new Set([...a].filter(x => !b.has(x)))
- _newControllers = [..._newControllers]
- this.setState(
- {
- nextUp: _newControllers
- },
- () => {
- ;(async () => {
- const nextUpBalances = await Promise.all(
- _this.state.nextUp.map(authorityId => polkadotAPI.accountInfo(authorityId))
- )
- _this.setState({
- nextUpBalances
- })
- })()
- }
- )
- })
- })()
- }
- }
-
- Validate() {
- this.props.navigation.navigate('Stake')
- }
-
- Unvalidate() {
- this.props.navigation.navigate('Unstake')
- }
-
- Nominate() {
- this.props.rootStore.stateStore.tonominate = 0
- this.props.navigation.navigate('Nominate', { address: '' })
- }
-
- componentWillMount() {
- if (Platform.OS == 'android') {
- StatusBar.setBackgroundColor('#F14B79')
- StatusBar.setBarStyle('light-content')
- }
- if (this.state.curTab == 1) {
- this.initPage()
- } else {
- this.AccountActions()
- }
- }
-
- componentDidMount() {
- // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
- // Start listening through addListener, didFocus RN lifecycle, page gets focus
- this._didBlurSubscription = this.props.navigation.addListener('didFocus', () => {
- if (this.state.curTab == 2) {
- this.refresh(2)
- } else if (this.state.eraLength == 0) {
- this.initPage()
- }
- if (Platform.OS == 'android') {
- StatusBar.setBackgroundColor('#F14B79')
- }
- StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
- })
- }
-
- componentWillUnmount() {
- // 在页面消失的时候,取消监听
- // Unlisten when the page disappears
- this._didBlurSubscription && this._didBlurSubscription.remove()
- }
-
- render() {
- return (
-
-
-
-
-
-
-
- {i18n.t('TAB.Staking')}
-
-
- {
- this.setState({
- curTab: 1
- })
- }}
- style={{ justifyContent: 'center', alignItems: 'center', width: ScreenWidth * 0.5 }}
- >
-
-
- {i18n.t('Staking.stakingOverview')}
-
-
-
-
-
-
-
- {i18n.t('Staking.AccountActions')}
-
-
-
-
-
-
-
-
-
- }
- style={{ height: ScreenHeight - 98 }}
- >
- {this.state.curTab == 1 ? (
-
-
-
-
-
- {/* validators */}
-
-
- {i18n.t('Staking.validatorsNum')}
-
-
- {`${this.state.validatorNum}/${this.state.validatorCount}`}
-
-
- {/* intentions */}
-
-
- {i18n.t('Staking.intentions')}
-
- {this.state.intentionNum}
-
-
-
- {/* session */}
-
-
- {i18n.t('Staking.session')}
-
-
- {`${this.state.sessionProgress}/${this.state.sessionLength}`}
-
-
- {/* era */}
-
-
- {i18n.t('Staking.era')}
-
-
- {`${this.state.eraProgress}/${this.state.eraLength}`}
-
-
-
-
-
-
- {
- this.setState({
- titlebottomSO: 1
- })
- }}
- >
-
-
- {i18n.t('Staking.validators')}
-
-
-
-
-
-
-
- {i18n.t('Staking.nextUp')}
-
-
-
-
-
-
-
- {this.state.titlebottomSO == 1 ? ( // Validators
- this.state.validatorNum == 0 ? (
-
- {i18n.t('Staking.NoValidator')}
-
- ) : (
- this.state.validators.map((item, index) => (
-
-
-
-
- {String(formatData(item).stashId)}
-
-
-
- {`${formatBalance(String(Number(formatData(item).stakers.own)))}(+${formatBalance(
- Number(formatData(item).stakers.total) - Number(formatData(item).stakers.own)
- )})`}
-
-
- ))
- )
- ) : this.state.nextUp.length == 0 ? ( // Next up没有数据 | Not have data
-
- {i18n.t('Staking.NoValidator')}
-
- ) : (
- this.state.nextUp.map((item, index) => (
-
-
-
-
- {String(item)}
-
-
-
- {this.state.nextUpBalances.length > 0
- ? formatBalance(
- String(Number(formatData(this.state.nextUpBalances[index]).stakingLedger.active))
- )
- : '0'}
-
-
- ))
- )}
-
-
-
- ) : (
-
- {/* 顶部导航栏加tab切换 */}
-
-
-
- {/* 图表 | chart */}
-
-
-
- {/* 个人信息 | account info */}
-
-
-
- {this.state.controllerAccountTag && (
-
-
-
- )}
-
-
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].account}
-
-
- {/* 控制账户或者储存账户信息 | Control or stash account info */}
-
- {((this.state.stashAccountTag && this.state.controllersAccount) ||
- this.state.controllerAccountTag) && (
-
-
-
- {this.state.stashAccountTag ? i18n.t('Staking.controller') : i18n.t('Staking.stash')}
-
-
- {this.state.stashAccountTag
- ? this.state.controllersAccount
- : this.state.controllerToStash.address}
-
- {this.state.controllerAccountTag && (
-
- {formatBalance(String(this.state.controllerToStash.polkakey || '1000000000'))}
-
- )}
-
- )}
-
-
- {/* 不同账户显示不同类型的余额信息 | Different accounts display balance info */}
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
- {this.state.stashAccountTag && this.state.controllersAccount ? (
-
-
- {`available ${formatBalance(this.state.AccountMsg.available)}`}
-
- {/* balance */}
-
- {i18n.t('Staking.balance')}
- {` ${formatBalance(this.state.AccountMsg.balance)}`}
-
- {/* bonded */}
-
- {`bonded ${formatBalance(this.state.AccountMsg.bonded)}`}
-
- {/* lockedes */}
- {this.state.AccountMsg.lockedes.map((v, i) => (
-
- {i18n.t('Staking.locked')}
- {` ${formatBalance(v.value)}(${v.era} ${i18n.t('Staking.eraLeft')})`}
-
- ))}
-
- ) : (
-
- {i18n.t('Staking.balance')}
- {` ${formatBalance(this.state.AccountMsg.balance)}`}
-
- )}
-
-
- {/* 根据不同的账户状态显示不同的按钮 | Different accounts display buttons */}
- {this.state.showBtnType == 0 ? (
-
- ) : // 0 不展示 | Not to show
- this.state.showBtnType == 1 ? ( // 1.追加绑定 | AddBond
-
-
- {i18n.t('Staking.BondAdditional')}
-
-
- ) : this.state.showBtnType == 2 ? ( // 2.追加绑定禁止点击 | Can't click AddBodn button
-
-
- {i18n.t('Staking.BondAdditional')}
-
-
- ) : this.state.showBtnType == 3 ? ( // 3. 取消提名 | Unnominate
-
-
-
- {i18n.t('Staking.Unnominate')}
-
-
- ) : this.state.showBtnType == 4 ? ( // 4.取消验证 | Unvalidate
-
-
-
- {i18n.t('Staking.Unvalidate')}
-
-
- ) : this.state.showBtnType == 5 ? ( // 5.提名 + 验证 | nominate + validate
-
-
-
- {i18n.t('Staking.Validate')}
-
-
-
- {i18n.t('Staking.Nominate')}
-
-
- ) : (
- // 6.绑定 | Bond
-
-
- {i18n.t('Staking.BondFunds')}
-
-
- )}
-
- {/* ACCOUNT Tab Switch */}
-
- {
- this.setState({
- titlebottomAA: 1
- })
- }}
- style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
- >
-
-
- {i18n.t('Staking.SlashRecords')}
-
-
-
-
- {
- this.setState({
- titlebottomAA: 2
- })
- }}
- style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
- >
-
-
- {i18n.t('Staking.Nominating')}
-
-
-
-
- {
- this.setState({
- titlebottomAA: 3
- })
- }}
- style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
- >
-
-
- {i18n.t('Staking.MyNominators')}
-
-
-
-
-
- {this.state.titlebottomAA == 1 ? (
- // Staking Recored
-
- {this.state.staking_list_alexander.length > 0 ? (
- this.state.staking_list_alexander.map((item, index) => (
-
-
-
-
- {i18n.t('TAB.Staking')}
- {` ${item.st_type}`}
-
- {moment(item.st_timestamp).format('DD/MM/YYYY HH:mm:ss')}
-
-
- {item.st_type == 'slashed' ? '- ' : '+ '}
- {formatBalance(String(item.st_balance))}
-
-
- ))
- ) : this.state.hasNextPage ? (
-
-
- {i18n.t('TAB.loadMore')}
-
-
- ) : (
-
- {i18n.t('TAB.Bottom')}
-
- )}
-
- ) : this.state.titlebottomAA == 2 ? (
-
- {this.state.nominating.length == 0 ? (
-
-
- {i18n.t('Staking.noNominating')}
-
-
- ) : (
- this.state.nominating.map((v, i) => (
-
-
-
-
- {String(v)}
-
-
-
- {this.state.nominatingBalance.length > 0 ? (
- formatData(this.state.nominatingBalance[i]).stakers ? (
- `${formatBalance(
- String(Number(formatData(this.state.nominatingBalance[i]).stakers.own))
- )}(+${formatBalance(
- String(
- Number(formatData(this.state.nominatingBalance[i]).stakers.total) -
- Number(formatData(this.state.nominatingBalance[i]).stakers.own)
- )
- )})`
- ) : (
- 0
- )
- ) : (
- '0'
- )}
-
-
- ))
- )}
-
- ) : this.state.titlebottomAA == 3 ? (
-
- {this.state.myNominators.length == 0 ? (
-
-
- {i18n.t('Staking.noNominee')}
-
-
- ) : (
- this.state.myNominators.map((item, index) => (
-
-
-
-
- {formatData(item).who}
-
-
-
- {formatBalance(formatData(item).value)}
-
-
- ))
- )}
-
- ) : (
-
- )}
-
-
- )}
-
-
-
- )
- }
-}
-
-export default Staking
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ TouchableOpacity,
+ ScrollView,
+ Image,
+ RefreshControl,
+ SafeAreaView,
+ Platform,
+ ImageBackground,
+ StatusBar,
+ Alert,
+ InteractionManager
+} from 'react-native'
+import moment from 'moment/moment'
+import Identicon from 'polkadot-identicon-react-native'
+import { formatBalance } from '@polkadot/util'
+import Echarts from 'native-echarts'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, formatData, axios, doubleClick } from '../../util/Common'
+import polkadotAPI from '../../util/polkadotAPI'
+import i18n from '../../locales/i18n'
+
+const styles = StyleSheet.create({
+ navContent: {
+ width: ScreenWidth,
+ height: 77,
+ alignItems: 'center'
+ }
+})
+@inject('rootStore')
+@observer
+class Staking extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ stashAccountTag: false,
+ controllerAccountTag: false,
+ curTab: 1, // 当前tab | The current tab
+ isrefresh: false, // 隐藏刷新 | Hide the refresh
+ isselectJumpPageShow: false,
+ validators: [],
+ validatorNum: 0,
+ validatorCount: 0,
+
+ intentions: [],
+ intentionNum: 0,
+
+ sessionProgress: 0,
+ sessionLength: 0,
+
+ eraProgress: 0,
+ eraLength: 0,
+
+ titlebottomSO: 1, // Validators 和 Next up 的tab切换 | Switch Validators and Next up's tab
+
+ nextUp: [], // next Up 集合 | collection of next Up
+ nextUpBalances: [], // next up 余额集合 | collection of next Up balance
+
+ StakingOption: {
+ title: {
+ text: i18n.t('Staking.stakingOption'),
+ textStyle: {
+ color: '#3E2D32',
+ fontSize: 16
+ },
+ padding: [0, 0, 0, 0]
+ },
+ tooltip: {},
+ legend: {
+ data: ['']
+ },
+ grid: {
+ left: 5
+ },
+ xAxis: {
+ axisLine: {
+ show: false
+ },
+ data: []
+ },
+ yAxis: {
+ axisLine: {
+ show: false
+ },
+ position: 'right'
+ },
+ color: ['#FF5080'],
+ series: [
+ {
+ type: 'line',
+ smooth: true,
+ data: []
+ }
+ ]
+ },
+
+ AccountMsg: {
+ // 默认账户信息
+ // Default account information
+ available: 0,
+ balance: 0,
+ bonded: 0,
+ lockedes: []
+ },
+ controllerToStash: {},
+ controllersAccount: '', // 控制账户信息 | Control account information
+ accountChangeTag: false, // 账户相关的按钮是否可以点击 | Whether the operation buttons can be clicked
+ // showBtnType: 0: Not show, 1: Unbond + AddBond, 2: Unbond, 3: Unnominate, 4: Unvalidate, 5: nominate + validate, 6: bond
+ showBtnType: 0, // 0 不展示 1.解绑 + 追加绑定 2.解绑 3. 取消提名 4.取消验证 5.提名 + 验证 6.绑定
+ titlebottomAA: 1, // Slash Records 、Nominating、MyNominators tab切换的tab值
+ staking_list_alexander: [], // Slash Records
+ pageNum: 1, // Slash Records 的页数 | Slash Records pages Number
+ hasNextPage: false, // Slash Records 是否有下一页 | Is there a next page of Slash Records?
+ nominating: [], // nominating 的合集
+ nominatingBalance: [], // nominating 所有账户余额的集合
+ myNominators: [] // myNominators 的合集
+ }
+ }
+
+ /**
+ * @description 页面初始化 加载所需数据|The page initializes the required data
+ */
+ initPage() {
+ ;(async () => {
+ const _this = this
+ // Query all
+ let validatorCount
+ let sessionLength
+ let eraLength
+ ;[validatorCount, sessionLength, eraLength] = await Promise.all([
+ polkadotAPI.validatorCount(),
+ polkadotAPI.sessionLength(),
+ polkadotAPI.eraLength()
+ ])
+
+ _this.setState({
+ validatorCount,
+ sessionLength,
+ eraLength
+ })
+ polkadotAPI.sessionProgress(sessionProgress => {
+ _this.setState({
+ sessionProgress
+ })
+ })
+ polkadotAPI.eraProgress(eraProgress => {
+ _this.setState({
+ eraProgress
+ })
+ })
+
+ const oldvalidators = await polkadotAPI.validators()
+
+ const newValidators = await Promise.all(oldvalidators.map(authorityId => polkadotAPI.accountInfo(authorityId)))
+ _this.setState({
+ validators: newValidators,
+ validatorNum: newValidators.length
+ })
+
+ await polkadotAPI.controllers(intentions => {
+ _this.setState({
+ intentions: intentions[0],
+ intentionNum: intentions[0].length
+ })
+ })
+ })()
+ }
+
+ /**
+ * @description 切换 account Actions 加载信息
+ */
+ loadAccountActions() {
+ ;(async () => {
+ this.loadSlashRecords()
+ this.getStakingOption(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
+ let address = await polkadotAPI.bonded(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ ) // 检测是否为“存储账户(stash)" | The account is stash account?
+ address = String(address)
+ if (address) {
+ // 存储账户(stash)
+ this.setState({
+ controllerAccountTag: false,
+ stashAccountTag: true
+ })
+ this.setState({
+ controllersAccount: String(address),
+ accountChangeTag: true
+ })
+ let AccountMsg = await polkadotAPI.accountInfo(String(address)) // 查对应的控制账户信息 | Check the control account info
+ AccountMsg = formatData(AccountMsg).stakingLedger
+
+ let allLockedValue = 0 // 所有解绑的值 | All of the unbound values
+ const lockedes = [] // 解绑中的每个对象的集合 | Object of Unbond
+ let balance = await polkadotAPI.freeBalance(
+ String(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
+ ) // 余额 | Balance
+ const bonded = Number(AccountMsg.active)
+ balance = String(Number(balance))
+
+ if (AccountMsg.unlocking.length > 0) {
+ // 解绑中的数量大于1
+ // The number of unbond is greater than 1
+ for (let i = 0; i < AccountMsg.unlocking.length; i++) {
+ allLockedValue = String(Number(allLockedValue) + Number(AccountMsg.unlocking[i].value))
+ lockedes.push({
+ value: AccountMsg.unlocking[i].value,
+ era: AccountMsg.unlocking[i].era
+ })
+ }
+ }
+
+ const available = balance - bonded - allLockedValue
+
+ this.setState({
+ AccountMsg: {
+ available,
+ balance,
+ bonded,
+ lockedes
+ }
+ })
+ if (available == 0) {
+ // 显示Unbond 隐藏Bond Additional
+ // Show Unbond, hide Bond Additional
+ this.setState({
+ showBtnType: 2
+ })
+ } else if (available != 0) {
+ // 显示Bond Additional和Unbond 按钮
+ // Displays Bond Additional and Unbond buttons
+ this.setState({
+ showBtnType: 1
+ })
+ }
+ } else {
+ // 不是储存账户
+ // Not is stash account
+ this.setState({
+ stashAccountTag: false
+ })
+ const balance = await polkadotAPI.freeBalance(
+ String(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
+ )
+ const AccountMsg = await polkadotAPI.accountInfo(
+ String(this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address)
+ ) // 查对应的控制账户信息 | Check the control account info
+ this.setState({
+ AccountMsg: {
+ balance
+ }
+ })
+ let controller = await polkadotAPI.ledger(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ ) // 判断是否为控制账户 | Determine whether it is a control account
+ controller = formatData(controller)
+ if (controller && controller != null && controller != 'null') {
+ // 如果是控制账户
+ // Is control account
+ this.setState({
+ controllerAccountTag: true,
+ controllerToStash: {
+ address: String(AccountMsg.stakingLedger.stash),
+ polkakey: AccountMsg.stakingLedger.active
+ }
+ })
+
+ if (this.state.intentions.length == 0) {
+ await polkadotAPI.controllers(intentions => {
+ this.setState(
+ {
+ intentions: formatData(intentions[0]),
+ intentionNum: intentions[0].length
+ },
+ () => {
+ if (this.state.intentions.includes(String(controller.stash))) {
+ // 验证状态 显示停止验证
+ // Validation status, displays stop validate
+ this.setState({
+ showBtnType: 4
+ })
+ } else {
+ // 判断提名
+ // Determine the nomination
+ ;(async () => {
+ const info = await polkadotAPI.accountInfo(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ const nominating = formatData(info).nominators
+ if (nominating.length > 0) {
+ // 提名个数大于0 正在提名 显示停止提名
+ // When the number of nominators is greater than 0, display stops nominate
+ this.setState({
+ showBtnType: 3
+ })
+ } else {
+ // 既没有验证 也 没有提名 显示验证和提名
+ // Neither validate nor nominate, shows validate and nominate
+ this.setState({
+ showBtnType: 5
+ })
+ }
+ })()
+ }
+ }
+ )
+ })
+ } else if (this.state.intentions.includes(controller.stash)) {
+ // 验证状态 显示停止验证
+ // validate status, displays stop validate
+ this.setState({
+ showBtnType: 4
+ })
+ } else {
+ // 判断提名
+ // Determine the nominate
+ const info = await polkadotAPI.accountInfo(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ const nominating = formatData(info).nominators
+ if (nominating.length > 0) {
+ // 提名个数大于0 正在提名 显示停止提名
+ // When the number of nominators is greater than 0, display stops nominate
+ this.setState({
+ showBtnType: 3
+ })
+ } else {
+ // 既没有验证 也 没有提名 显示验证和提名
+ // Neither validate nor nominate, shows validate and nominate
+ this.setState({
+ showBtnType: 5
+ })
+ }
+ }
+ } else {
+ // 显示绑定bond 按钮
+ // Show the Bond button
+ this.setState({
+ controllerAccountTag: false,
+ showBtnType: 6
+ })
+ }
+ }
+
+ const info = await polkadotAPI.accountInfo(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ const nominating = formatData(info).nominators
+ const nominatingBalance = await Promise.all(
+ nominating.map(authorityId => polkadotAPI.accountInfo(String(authorityId)))
+ )
+ this.setState({
+ nominating: nominating || [],
+ nominatingBalance: nominatingBalance || [],
+ myNominators: formatData(info).stakers.others
+ })
+ })()
+ }
+
+ /**
+ * @description 点击切换 account Actions
+ */
+ AccountActions() {
+ this.setState(
+ {
+ curTab: 2
+ },
+ () => {
+ this.loadAccountActions()
+ }
+ )
+ }
+
+ /**
+ * @description 加载SlashRecords数据
+ * @param {Number} pageNum 页数
+ */
+ loadSlashRecords(pageNum = 1) {
+ const _this = this
+ const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_list_alexander'
+ let params = {
+ pageNum,
+ pageSize: 10,
+ user_address: this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ }
+ params = JSON.stringify(params)
+ axios(REQUEST_URL, params)
+ .then(result => {
+ let staking_list_alexander = []
+ if (pageNum == 1) {
+ staking_list_alexander = result.staking_list_alexander.list
+ } else {
+ staking_list_alexander = [...this.state.staking_list_alexander, result.staking_list_alexander.list]
+ }
+ _this.setState({
+ hasNextPage: result.staking_list_alexander.hasNextPage,
+ staking_list_alexander
+ })
+ })
+ .catch()
+ }
+
+ /**
+ * @description 分页加载 Slash Records|Paging load slash Records
+ */
+ Loadmore() {
+ this.setState(
+ {
+ pageNum: this.state.pageNum + 1
+ },
+ () => {
+ this.loadSlashRecords(this.state.pageNum)
+ }
+ )
+ }
+
+ /**
+ * @description 获取当前账户折线图数据|Get the current account chart data
+ * @param {String} address 地址|Address
+ */
+ getStakingOption(address) {
+ const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_chart_alexander'
+ const params = `{"user_address":"${String(address)}","UTCdate":"${moment(new Date().getTime()).format(
+ 'YYYY-MM-DD HH:mm:ss'
+ )}"}`
+ axios(REQUEST_URL, params)
+ .then(result => {
+ const _StakingOption = {
+ title: {
+ text: i18n.t('Staking.stakingOption'),
+ textStyle: {
+ color: '#3E2D32',
+ fontSize: 16
+ },
+ padding: [0, 0, 0, 0]
+ },
+ tooltip: {},
+ legend: {
+ data: ['']
+ },
+ grid: {
+ left: 5
+ },
+ xAxis: {
+ axisLine: {
+ show: false
+ },
+ data: []
+ },
+ yAxis: {
+ axisLine: {
+ show: false
+ },
+ position: 'right'
+ },
+ color: ['#FF5080'],
+ series: [
+ {
+ type: 'line',
+ smooth: true,
+ data: []
+ }
+ ]
+ }
+ result.map(item => {
+ _StakingOption.xAxis.data.push(`${item.time.substring(5, 7)}/${item.time.substring(8, 10)}`)
+ _StakingOption.series[0].data.push((item.slash_balance / 1000000).toFixed(1))
+ })
+ let max = 0
+ for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
+ if (_StakingOption.series[0].data[i] > max) {
+ max = _StakingOption.series[0].data[i]
+ }
+ }
+ const power =
+ formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).power +
+ formatBalance.getDefaults().decimals
+ const unit = formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).text
+ for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
+ _StakingOption.series[0].data[i] = (_StakingOption.series[0].data[i] / Number(Math.pow(10, power))).toFixed(3)
+ }
+ _StakingOption.title.text = `${i18n.t('Staking.stakingOption_new')} ( ${unit} )`
+ this.setState({
+ StakingOption: _StakingOption
+ })
+ })
+ .catch()
+ }
+
+ /**
+ * @description 刷新|refresh
+ * @param {*} type 当前在那个tab|Currently on the tab
+ */
+ refresh(type) {
+ this.setState({
+ isrefresh: true
+ })
+ if (type == 1) {
+ this.setState(
+ {
+ validators: [],
+ validatorNum: 0,
+ validatorCount: 0,
+
+ intentions: [],
+ intentionNum: 0,
+
+ sessionProgress: 0,
+ sessionLength: 0,
+
+ eraProgress: 0,
+ eraLength: 0,
+
+ titlebottomSO: 1, // Validators 和 Next up 的tab切换
+
+ nextUp: [], // next Up 集合
+ nextUpBalances: [] // next up 余额集合
+ },
+ () => {
+ this.setState({
+ isrefresh: false
+ })
+ this.initPage()
+ }
+ )
+ } else if (type == 2) {
+ this.setState(
+ {
+ controllerAccountTag: false,
+ stashAccountTag: true,
+ StakingOption: {
+ title: {
+ text: i18n.t('Staking.stakingOption'),
+ textStyle: {
+ color: 'grey',
+ fontSize: 16
+ }
+ },
+
+ tooltip: {
+ triggerOn: 'none'
+ },
+ legend: {
+ data: ['']
+ },
+ xAxis: {
+ axisPointer: { handle: { show: true } },
+
+ axisLine: {
+ show: false
+ },
+ data: []
+ },
+ yAxis: {
+ axisLine: {
+ show: false
+ },
+ position: 'right'
+ },
+ color: ['#FF5080'],
+ series: [
+ {
+ type: 'line',
+ smooth: true,
+ data: []
+ }
+ ]
+ },
+ intentions: [],
+ intentionNum: 0,
+ AccountMsg: {
+ // 默认账户信息
+ available: 0,
+ balance: 0,
+ bonded: 0,
+ lockedes: []
+ },
+
+ controllersAccount: '', // 控制账户信息 | Control account information
+ accountChangeTag: false, // 账户相关的按钮是否可以点击 | Whether the operation buttons can be clicked
+ // showBtnType: 0: Not show, 1: Unbond + AddBond, 2: Unbond, 3: Unnominate, 4: Unvalidate, 5: nominate + validate, 6: bond
+ showBtnType: 0, // 0 不展示 1.解绑 + 追加绑定 2.解绑 3. 取消提名 4.取消验证 5.提名 + 验证 6.绑定
+ titlebottomAA: 1, // Slash Records 、Nominating、MyNominators tab切换的tab值
+ staking_list_alexander: [], // Slash Records
+ pageNum: 1, // Slash Records 的页数 | Slash Records pages Number
+ hasNextPage: false, // Slash Records 是否有下一页| Is there a next page of Slash Records?
+ nominating: [], // nominating 的合集
+ nominatingBalance: [], // nominating 所有账户余额的集合
+ myNominators: [] // myNominators 的合集
+ },
+ () => {
+ this.setState({
+ isrefresh: false
+ })
+ this.AccountActions()
+ }
+ )
+ }
+ }
+
+ /**
+ * @description 跳转个人信息界面|Jump to the personal information interface
+ * @param {String} address 地址|Address
+ */
+ toValidator_Info(address) {
+ this.props.navigation.navigate('Validator_Info', { address: String(address) })
+ }
+
+ /**
+ * @description 跳转 stake 页面|Jump to the stake page
+ */
+ stake() {
+ this.props.navigation.navigate('Stake')
+ }
+
+ /**
+ * @description 跳转 Unstake 页面|Jump to the Unstake page
+ */
+ Unstake() {
+ this.props.navigation.navigate('Unstake')
+ }
+
+ /**
+ * @description 跳转 Unnominate 页面|Jump to the Unnominate page
+ */
+ Unnominate() {
+ this.props.navigation.navigate('Unnominate')
+ }
+
+ /**
+ * @description 跳转 Nominate 页面|Jump to the Nominate page
+ */
+ nominate() {
+ this.props.rootStore.stateStore.tonominate = 0
+ this.props.navigation.navigate('Nominate', { address: '' })
+ }
+
+ /**
+ * @description 跳转 BondAdditional 页面|Jump to the BondAdditional page
+ */
+ BondAdditional() {
+ this.props.navigation.navigate('BondAdditional')
+ }
+
+ /**
+ * @description 选择操作|Select operation
+ */
+ selectJumpPage() {
+ Alert.alert(
+ '',
+ i18n.t('Staking.PleaseChoose'),
+ [
+ {
+ text: i18n.t('Staking.Unbond'),
+ onPress: () => {
+ this.Unbond()
+ }
+ },
+ {
+ text: i18n.t('Staking.SetSessionKey'),
+ onPress: () => {
+ this.setSessionKey()
+ }
+ },
+ {
+ text: i18n.t('TAB.Cancel'),
+ onPress: () => {},
+ style: 'cancel'
+ }
+ ],
+ { cancelable: true }
+ )
+ }
+
+ /**
+ * @description 跳转 SetSessionKey 页面|Jump to the SetSeesionkey
+ */
+ setSessionKey() {
+ this.props.navigation.navigate('SetSessionKey')
+ }
+
+ /**
+ * @description 跳转 Unbond 页面|Jump to the Unbond page
+ */
+ Unbond() {
+ this.props.navigation.navigate('Unbond')
+ }
+
+ /**
+ * @description 跳转 BondFunds 页面|Jump to the BondFunds
+ */
+ BondFunds() {
+ this.props.navigation.navigate('BondFunds')
+ }
+
+ /**
+ * @description 下边tab切换|The TAB to switch
+ */
+ changeSOIndex() {
+ const _this = this
+ this.setState({
+ titlebottomSO: 2
+ })
+ if (this.state.nextUp.length == 0 && this.state.validators.length != 0) {
+ ;(async () => {
+ polkadotAPI.controllers(controllers => {
+ const _validators = []
+ const _controllers = []
+ let _newControllers = []
+ this.state.validators.map(item => {
+ _validators.push(String(formatData(item).stashId))
+ })
+ controllers[0].map(item => {
+ _controllers.push(String(formatData(item)))
+ })
+ const a = new Set(_controllers)
+ const b = new Set(_validators)
+ _newControllers = new Set([...a].filter(x => !b.has(x)))
+ _newControllers = [..._newControllers]
+ this.setState(
+ {
+ nextUp: _newControllers
+ },
+ () => {
+ ;(async () => {
+ const nextUpBalances = await Promise.all(
+ _this.state.nextUp.map(authorityId => polkadotAPI.accountInfo(authorityId))
+ )
+ _this.setState({
+ nextUpBalances
+ })
+ })()
+ }
+ )
+ })
+ })()
+ }
+ }
+
+ /**
+ * @description 跳转 Stake 页面|Jump to Stake page
+ */
+ Validate() {
+ this.props.navigation.navigate('Stake')
+ }
+
+ /**
+ * @description 跳转 Unstake 页面|Jump to the Unstake page
+ */
+ Unvalidate() {
+ this.props.navigation.navigate('Unstake')
+ }
+
+ /**
+ * @description 跳转 Nominate 页面|Jump to the Nominate page
+ */
+ Nominate() {
+ this.props.rootStore.stateStore.tonominate = 0
+ this.props.navigation.navigate('Nominate', { address: '' })
+ }
+
+ componentWillMount() {
+ // 通过addListener开启监听,didFocus RN 生命周期 页面获取焦点
+ // Start listening through addListener, didFocus RN lifecycle, page gets focus
+ this._didBlurSubscription = this.props.navigation.addListener('didFocus', () => {
+ if (this.state.curTab == 2) {
+ this.refresh(2)
+ } else if (this.state.eraLength == 0) {
+ this.initPage()
+ }
+ if (Platform.OS == 'android') {
+ StatusBar.setBackgroundColor('#F14B79')
+ }
+ StatusBar.setBarStyle(Platform.OS == 'android' ? 'light-content' : 'dark-content')
+ })
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ if (Platform.OS == 'android') {
+ StatusBar.setBackgroundColor('#F14B79')
+ StatusBar.setBarStyle('light-content')
+ }
+ if (this.state.curTab == 1) {
+ this.initPage()
+ } else {
+ this.AccountActions()
+ }
+ })
+ }
+
+ componentWillUnmount() {
+ // 在页面消失的时候,取消监听
+ // Unlisten when the page disappears
+ this._didBlurSubscription && this._didBlurSubscription.remove()
+ }
+
+ render() {
+ return (
+
+
+
+
+
+
+
+ {i18n.t('TAB.Staking')}
+
+
+ {
+ this.setState({
+ curTab: 1
+ })
+ }}
+ activeOpacity={0.7}
+ style={{ justifyContent: 'center', alignItems: 'center', width: ScreenWidth * 0.5 }}
+ >
+
+
+ {i18n.t('Staking.stakingOverview')}
+
+
+
+
+
+
+
+ {i18n.t('Staking.AccountActions')}
+
+
+
+
+
+
+
+
+
+ }
+ style={{ height: ScreenHeight - 98 }}
+ >
+ {this.state.curTab == 1 ? (
+
+
+
+
+
+ {/* validators */}
+
+
+ {i18n.t('Staking.validatorsNum')}
+
+
+ {`${this.state.validatorNum}/${this.state.validatorCount}`}
+
+
+ {/* intentions */}
+
+
+ {i18n.t('Staking.intentions')}
+
+ {this.state.intentionNum}
+
+
+
+ {/* session */}
+
+
+ {i18n.t('Staking.session')}
+
+
+ {`${this.state.sessionProgress}/${this.state.sessionLength}`}
+
+
+ {/* era */}
+
+
+ {i18n.t('Staking.era')}
+
+
+ {`${this.state.eraProgress}/${this.state.eraLength}`}
+
+
+
+
+
+
+ {
+ this.setState({
+ titlebottomSO: 1
+ })
+ }}
+ activeOpacity={0.7}
+ >
+
+
+ {i18n.t('Staking.validators')}
+
+
+
+
+
+
+
+ {i18n.t('Staking.nextUp')}
+
+
+
+
+
+
+
+ {this.state.titlebottomSO == 1 ? ( // Validators
+ this.state.validatorNum == 0 ? (
+
+ {i18n.t('Staking.NoValidator')}
+
+ ) : (
+ this.state.validators.map((item, index) => (
+
+
+
+
+ {String(formatData(item).stashId)}
+
+
+
+ {`${formatBalance(String(Number(formatData(item).stakers.own)))}(+${formatBalance(
+ Number(formatData(item).stakers.total) - Number(formatData(item).stakers.own)
+ )})`}
+
+
+ ))
+ )
+ ) : this.state.nextUp.length == 0 ? ( // Next up没有数据 | Not have data
+
+ {i18n.t('Staking.NoValidator')}
+
+ ) : (
+ this.state.nextUp.map((item, index) => (
+
+
+
+
+ {String(item)}
+
+
+
+ {this.state.nextUpBalances.length > 0
+ ? formatBalance(
+ String(Number(formatData(this.state.nextUpBalances[index]).stakingLedger.active))
+ )
+ : '0'}
+
+
+ ))
+ )}
+
+
+
+ ) : (
+
+ {/* 顶部导航栏加tab切换 */}
+
+
+
+ {/* 图表 | chart */}
+
+
+
+ {/* 个人信息 | account info */}
+
+
+
+ {this.state.controllerAccountTag && (
+ {
+ doubleClick(this.selectJumpPage.bind(this))
+ }}
+ >
+
+
+ )}
+
+
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].account}
+
+
+ {/* 控制账户或者储存账户信息 | Control or stash account info */}
+
+ {((this.state.stashAccountTag && this.state.controllersAccount) ||
+ this.state.controllerAccountTag) && (
+
+
+
+ {this.state.stashAccountTag ? i18n.t('Staking.controller') : i18n.t('Staking.stash')}
+
+
+ {this.state.stashAccountTag
+ ? this.state.controllersAccount
+ : this.state.controllerToStash.address}
+
+ {this.state.controllerAccountTag && (
+
+ {formatBalance(String(this.state.controllerToStash.polkakey || '1000000000'))}
+
+ )}
+
+ )}
+
+
+ {/* 不同账户显示不同类型的余额信息 | Different accounts display balance info */}
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+ {this.state.stashAccountTag && this.state.controllersAccount ? (
+
+
+ {`available ${formatBalance(this.state.AccountMsg.available)}`}
+
+ {/* balance */}
+
+ {i18n.t('Staking.balance')}
+ {` ${formatBalance(this.state.AccountMsg.balance)}`}
+
+ {/* bonded */}
+
+ {`bonded ${formatBalance(this.state.AccountMsg.bonded)}`}
+
+ {/* lockedes */}
+ {this.state.AccountMsg.lockedes.map((v, i) => (
+
+ {i18n.t('Staking.locked')}
+ {` ${formatBalance(v.value)}(${v.era} ${i18n.t('Staking.eraLeft')})`}
+
+ ))}
+
+ ) : (
+
+ {i18n.t('Staking.balance')}
+ {` ${formatBalance(this.state.AccountMsg.balance)}`}
+
+ )}
+
+
+ {/* 根据不同的账户状态显示不同的按钮 | Different accounts display buttons */}
+ {this.state.showBtnType == 0 ? (
+
+ ) : // 0 不展示 | Not to show
+ this.state.showBtnType == 1 ? ( // 1.追加绑定 | AddBond
+
+
+ {i18n.t('Staking.BondAdditional')}
+
+
+ ) : this.state.showBtnType == 2 ? ( // 2.追加绑定禁止点击 | Can't click AddBodn button
+
+
+ {i18n.t('Staking.BondAdditional')}
+
+
+ ) : this.state.showBtnType == 3 ? ( // 3. 取消提名 | Unnominate
+
+
+
+ {i18n.t('Staking.Unnominate')}
+
+
+ ) : this.state.showBtnType == 4 ? ( // 4.取消验证 | Unvalidate
+
+
+
+ {i18n.t('Staking.Unvalidate')}
+
+
+ ) : this.state.showBtnType == 5 ? ( // 5.提名 + 验证 | nominate + validate
+
+
+
+ {i18n.t('Staking.Validate')}
+
+
+
+ {i18n.t('Staking.Nominate')}
+
+
+ ) : (
+ // 6.绑定 | Bond
+
+
+ {i18n.t('Staking.BondFunds')}
+
+
+ )}
+
+ {/* ACCOUNT Tab Switch */}
+
+ {
+ this.setState({
+ titlebottomAA: 1
+ })
+ }}
+ activeOpacity={0.7}
+ style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
+ >
+
+
+ {i18n.t('Staking.SlashRecords')}
+
+
+
+
+ {
+ this.setState({
+ titlebottomAA: 2
+ })
+ }}
+ activeOpacity={0.7}
+ style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
+ >
+
+
+ {i18n.t('Staking.Nominating')}
+
+
+
+
+ {
+ this.setState({
+ titlebottomAA: 3
+ })
+ }}
+ activeOpacity={0.7}
+ style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
+ >
+
+
+ {i18n.t('Staking.MyNominators')}
+
+
+
+
+
+ {this.state.titlebottomAA == 1 ? (
+ // Staking Recored
+
+ {this.state.staking_list_alexander.length > 0 ? (
+ this.state.staking_list_alexander.map((item, index) => (
+
+
+
+
+ {i18n.t('TAB.Staking')}
+ {` ${item.st_type}`}
+
+ {moment(item.st_timestamp).format('DD/MM/YYYY HH:mm:ss')}
+
+
+ {item.st_type == 'slashed' ? '- ' : '+ '}
+ {formatBalance(String(item.st_balance))}
+
+
+ ))
+ ) : this.state.hasNextPage ? (
+
+
+ {i18n.t('TAB.loadMore')}
+
+
+ ) : (
+
+ {i18n.t('TAB.Bottom')}
+
+ )}
+
+ ) : this.state.titlebottomAA == 2 ? (
+
+ {this.state.nominating.length == 0 ? (
+
+
+ {i18n.t('Staking.noNominating')}
+
+
+ ) : (
+ this.state.nominating.map((v, i) => (
+
+
+
+
+ {String(v)}
+
+
+
+ {this.state.nominatingBalance.length > 0 ? (
+ formatData(this.state.nominatingBalance[i]).stakers ? (
+ `${formatBalance(
+ String(Number(formatData(this.state.nominatingBalance[i]).stakers.own))
+ )}(+${formatBalance(
+ String(
+ Number(formatData(this.state.nominatingBalance[i]).stakers.total) -
+ Number(formatData(this.state.nominatingBalance[i]).stakers.own)
+ )
+ )})`
+ ) : (
+ 0
+ )
+ ) : (
+ '0'
+ )}
+
+
+ ))
+ )}
+
+ ) : this.state.titlebottomAA == 3 ? (
+
+ {this.state.myNominators.length == 0 ? (
+
+
+ {i18n.t('Staking.noNominee')}
+
+
+ ) : (
+ this.state.myNominators.map((item, index) => (
+
+
+
+
+ {formatData(item).who}
+
+
+
+ {formatBalance(formatData(item).value)}
+
+
+ ))
+ )}
+
+ ) : (
+
+ )}
+
+
+ )}
+
+
+
+ )
+ }
+}
+
+export default Staking
diff --git a/src/page/Staking/secondary/BondAdditional.js b/src/page/Staking/secondary/BondAdditional.js
index 9c28e4a1..48479eca 100755
--- a/src/page/Staking/secondary/BondAdditional.js
+++ b/src/page/Staking/secondary/BondAdditional.js
@@ -1,534 +1,550 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-19 23:03:08
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- Modal,
- Alert,
- StatusBar,
- TouchableOpacity,
- SafeAreaView,
- Image
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { getUnit, ScreenWidth, ScreenHeight, formatData, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-import RNPicker from '../../../components/RNPicker'
-
-@inject('rootStore')
-@observer
-class BondAdditional extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- password: '',
- isModal: false,
- isWayModel: false,
- way: 'DOT',
- onlyone: 0,
- type: 'pending...',
- way_change: 'DOT',
- multiple: 1000000000000000,
- bondedValue: '',
- Failed: false
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
- this.Modify_way = this.Modify_way.bind(this)
- }
-
- // 更改密码
- // Change password
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- // 展示密码
- // Display password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // 更改单位
- // Switch units
- Modify_way(way_change) {
- this.setState({
- multiple: getUnit(way_change),
- isWayModel: false,
- way_change: way_change,
- way: way_change
- })
- }
-
- // bondedValue changed
- onChangeValue(bondedValue) {
- this.setState({
- bondedValue: String(bondedValue)
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 点击提交
- // Click Sign_and_Submit
- Sign_and_Submit() {
- if (this.state.bondedValue && this.state.password) {
- const _this = this
- this.setState({
- onlyone: 1,
- isModal: true
- })
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- _this.setState({
- onlyone: 1,
- isModal: true
- })
- const value = _this.state.bondedValue
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- let transfer
- try {
- let bondValue = Number(value) * Number(_this.state.multiple)
- transfer = await polkadotAPI.bondExtra(bondValue)
- } catch (e) {
- _this.setState({
- isModal: false,
- onlyone: 0,
- Failed: true
- })
- Alert.alert('', i18n.t('Staking.BondExtraFailed'))
- }
-
- transfer.signAndSend(loadPair, ({ status }) => {
- status = formatData(status)
- if (status.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success',
- Failed: false
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Staking.BondExtraSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- } else {
- Alert.alert('', i18n.t('TAB.enterInformation'))
- }
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
- {i18n.t('Staking.BondAdditional')}
-
- {i18n.t('TAB.signMess')}
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
-
-
- {i18n.t('Staking.calling')}
-
- staking.bondExtra
-
-
-
- {i18n.t('Staking.additionalValue')}
-
-
-
-
-
-
-
-
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Reset or Bond */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
- {i18n.t('Staking.BondExtra')}
-
- ) : (
-
- {i18n.t('Staking.BondExtra')}
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- middle: {
- justifyContent: 'center',
- alignItems: 'center'
- },
- chooses: {
- paddingLeft: ScreenWidth / 20,
- paddingRight: ScreenWidth / 20,
- alignItems: 'center',
- justifyContent: 'space-between',
- flexDirection: 'row',
- height: ScreenHeight / 18,
- backgroundColor: '#DCDCDC'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
-
- choose_Text: {
- fontWeight: '500',
- fontSize: ScreenHeight / 50,
- color: '#4169E1'
- },
- submit_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 2,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- Choose_way: {
- alignItems: 'center',
- marginLeft: ScreenWidth / 70,
- width: ScreenWidth * 0.25,
- height: ScreenHeight / 23,
- borderWidth: 1,
- borderRadius: ScreenHeight / 200,
- borderColor: '#4dabd0',
- flexDirection: 'row',
- backgroundColor: '#4dabd0'
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- },
- choessText: {
- fontWeight: '500',
- fontSize: ScreenWidth / 28,
- color: 'white'
- }
-})
-export default BondAdditional
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ Modal,
+ Alert,
+ StatusBar,
+ TouchableOpacity,
+ SafeAreaView,
+ Image
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { getUnit, ScreenWidth, ScreenHeight, formatData, checkPwd } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+import RNPicker from '../../../components/RNPicker'
+
+@inject('rootStore')
+@observer
+class BondAdditional extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ password: '',
+ isModal: false,
+ isWayModel: false,
+ way: 'DOT',
+ onlyone: 0,
+ type: 'pending...',
+ way_change: 'DOT',
+ multiple: 1000000000000000,
+ bondedValue: '',
+ Failed: false
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
+ this.Modify_way = this.Modify_way.bind(this)
+ }
+
+ /**
+ * @description 更改密码|Change password
+ * @param {String} Changepassword 密码
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description 展示密码|Display password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 更改单位|Switch units
+ * @param {String} way_change 单位
+ */
+ Modify_way(way_change) {
+ this.setState({
+ multiple: getUnit(way_change),
+ isWayModel: false,
+ way_change: way_change,
+ way: way_change
+ })
+ }
+
+ /**
+ * @description bondedValue 更改 |bondedValue changed
+ * @param {String | Number} bondedValue bondedValue值
+ */
+ onChangeValue(bondedValue) {
+ this.setState({
+ bondedValue: String(bondedValue)
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 点击提交|Click Sign_and_Submit
+ */
+ Sign_and_Submit() {
+ if (this.state.bondedValue && this.state.password) {
+ const _this = this
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ _this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const value = _this.state.bondedValue
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ let transfer
+ try {
+ let bondValue = Number(value) * Number(_this.state.multiple)
+ transfer = await polkadotAPI.bondExtra(bondValue)
+ } catch (e) {
+ _this.setState({
+ isModal: false,
+ onlyone: 0,
+ Failed: true
+ })
+ Alert.alert('', i18n.t('Staking.BondExtraFailed'))
+ }
+
+ transfer.signAndSend(loadPair, ({ status }) => {
+ status = formatData(status)
+ if (status.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success',
+ Failed: false
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Staking.BondExtraSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ } else {
+ Alert.alert('', i18n.t('TAB.enterInformation'))
+ }
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+ {i18n.t('Staking.BondAdditional')}
+
+ {i18n.t('TAB.signMess')}
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+
+
+ {i18n.t('Staking.calling')}
+
+ staking.bondExtra
+
+
+
+ {i18n.t('Staking.additionalValue')}
+
+
+
+
+
+
+
+
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Reset or Bond */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+
+ {i18n.t('Staking.BondExtra')}
+
+ ) : (
+
+ {i18n.t('Staking.BondExtra')}
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ middle: {
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ chooses: {
+ paddingLeft: ScreenWidth / 20,
+ paddingRight: ScreenWidth / 20,
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ flexDirection: 'row',
+ height: ScreenHeight / 18,
+ backgroundColor: '#DCDCDC'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+
+ choose_Text: {
+ fontWeight: '500',
+ fontSize: ScreenHeight / 50,
+ color: '#4169E1'
+ },
+ submit_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 2,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ Choose_way: {
+ alignItems: 'center',
+ marginLeft: ScreenWidth / 70,
+ width: ScreenWidth * 0.25,
+ height: ScreenHeight / 23,
+ borderWidth: 1,
+ borderRadius: ScreenHeight / 200,
+ borderColor: '#4dabd0',
+ flexDirection: 'row',
+ backgroundColor: '#4dabd0'
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ },
+ choessText: {
+ fontWeight: '500',
+ fontSize: ScreenWidth / 28,
+ color: 'white'
+ }
+})
+export default BondAdditional
diff --git a/src/page/Staking/secondary/BondFunds.js b/src/page/Staking/secondary/BondFunds.js
index 37808bf7..7467a244 100755
--- a/src/page/Staking/secondary/BondFunds.js
+++ b/src/page/Staking/secondary/BondFunds.js
@@ -1,618 +1,641 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 22:22:06
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- Modal,
- Alert,
- StatusBar,
- TouchableOpacity,
- Image,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { getUnit, ScreenWidth, ScreenHeight, formatData, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-import RNPicker from '../../../components/RNPicker'
-
-@inject('rootStore')
-@observer
-class BondFunds extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- password: '',
- isModal: false,
- isWayModel: false,
- way: 'DOT',
- onlyone: 0,
- type: 'pending...',
- way_change: 'DOT',
- multiple: 1000000000000000,
- bondedValue: '',
- ControllerValue: '',
- PayeeValue: '0',
- Failed: false
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
- this.Modify_way = this.Modify_way.bind(this)
- }
-
- // 密码修改
- // Change password
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- // 展示密码
- // Display password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // 更改单位
- // Switch units
- Modify_way(way_change) {
- this.setState({
- isWayModel: false,
- way_change: way_change,
- way: way_change,
- multiple: getUnit(way_change)
- })
- }
-
- onChangePayeeValue(PayeeValue) {
- this.setState({
- PayeeValue: String(PayeeValue)
- })
- }
-
- // ControllerValue
- onChangeControllerValue(ControllerValue) {
- this.setState({
- ControllerValue: String(ControllerValue)
- })
- }
-
- // bondedValue changed
- onChangeValue(bondedValue) {
- this.setState({
- bondedValue: String(bondedValue)
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 点击绑定
- // Click Bond
- Sign_and_Submit() {
- // bondedValue、ControllerValue、PayeeValue 和密码都输入了
- // All of bondedValue、ControllerValue、PayeeValue and password has been entered
- if (this.state.bondedValue && this.state.password && this.state.ControllerValue && this.state.PayeeValue) {
- const _this = this
- this.setState({
- onlyone: 1,
- isModal: true
- })
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- _this.setState({
- onlyone: 1,
- isModal: true
- })
- const controller = _this.state.ControllerValue
- const value = _this.state.bondedValue
- const payee = _this.state.PayeeValue
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- let transfer
- try {
- transfer = await polkadotAPI.bond(controller, Number(value) * Number(_this.state.multiple), Number(payee))
- } catch (e) {
- _this.setState({
- isModal: false,
- onlyone: 0,
- Failed: true
- })
- Alert.alert('', i18n.t('Staking.BondFailed'))
- }
- transfer.signAndSend(loadPair, ({ status }) => {
- status = formatData(status)
- if (status.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success',
- Failed: false
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Staking.BondSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- } else {
- Alert.alert('', i18n.t('TAB.enterInformation'))
- }
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
-
- {i18n.t('Staking.BondFunds')}
-
- {i18n.t('TAB.signMess')}
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
-
-
- {i18n.t('Staking.calling')}
-
- staking.bondExtra
-
-
-
-
- {i18n.t('Staking.Controller')}
-
-
-
-
-
-
- {i18n.t('Staking.payee')}
-
-
- this.setState({ PayeeValue: String(value) })}
- data={[
- {
- title: 'Stash account (increase the amount at stake)',
- value: '0'
- },
- {
- title: 'Stash account (do not increase the amount at stake)',
- value: '1'
- },
- {
- title: 'Controller account',
- value: '2'
- }
- ]}
- />
-
-
-
- {i18n.t('Staking.valueBonded')}
-
-
-
-
-
-
-
-
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Reset or Bond */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
- {i18n.t('Staking.BondFunds')}
-
- ) : (
-
- {i18n.t('Staking.BondFunds')}
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- middle: {
- justifyContent: 'center',
- alignItems: 'center'
- },
- chooses: {
- paddingLeft: ScreenWidth / 20,
- paddingRight: ScreenWidth / 20,
- alignItems: 'center',
- justifyContent: 'space-between',
- flexDirection: 'row',
- height: ScreenHeight / 18,
- backgroundColor: '#DCDCDC'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
-
- choose_Text: {
- fontWeight: '500',
- fontSize: ScreenHeight / 50,
- color: '#4169E1'
- },
- submit_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 1.3,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- Choose_way: {
- alignItems: 'center',
- marginLeft: ScreenWidth / 70,
- width: ScreenWidth * 0.25,
- height: ScreenHeight / 23,
- borderWidth: 1,
- borderRadius: ScreenHeight / 200,
- borderColor: '#4dabd0',
- flexDirection: 'row',
- backgroundColor: '#4dabd0'
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- },
- choessText: {
- fontWeight: '500',
- fontSize: ScreenWidth / 28,
- color: 'white'
- }
-})
-export default BondFunds
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ Modal,
+ Alert,
+ StatusBar,
+ TouchableOpacity,
+ Image,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { getUnit, ScreenWidth, ScreenHeight, formatData, checkPwd } from '../../../util/Common'
+import Header from '../../../components/Header'
+
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+import RNPicker from '../../../components/RNPicker'
+
+@inject('rootStore')
+@observer
+class BondFunds extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ password: '',
+ isModal: false,
+ isWayModel: false,
+ way: 'DOT',
+ onlyone: 0,
+ type: 'pending...',
+ way_change: 'DOT',
+ multiple: 1000000000000000,
+ bondedValue: '',
+ ControllerValue: '',
+ PayeeValue: '0',
+ Failed: false
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
+ this.Modify_way = this.Modify_way.bind(this)
+ }
+
+ /**
+ * @description 密码修改|Change password
+ * @param {String} Changepassword 密码
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description 展示密码|Display password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 更改单位|Switch units
+ * @param {String} way_change 单位|Units
+ */
+ Modify_way(way_change) {
+ this.setState({
+ isWayModel: false,
+ way_change: way_change,
+ way: way_change,
+ multiple: getUnit(way_change)
+ })
+ }
+
+ /**
+ * @description PayeeValue change
+ * @param {String} PayeeValue The value of PayeeValue
+ */
+ onChangePayeeValue(PayeeValue) {
+ this.setState({
+ PayeeValue: String(PayeeValue)
+ })
+ }
+
+ /**
+ * @description ControllerValue change
+ * @param {*} ControllerValue
+ */
+ onChangeControllerValue(ControllerValue) {
+ this.setState({
+ ControllerValue: String(ControllerValue)
+ })
+ }
+
+ /**
+ * @description bondedValue更改
+ * @param {String | Number} bondedValue The value of bondedValue
+ */
+ onChangeValue(bondedValue) {
+ this.setState({
+ bondedValue: String(bondedValue)
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 点击绑定|Click Bond
+ */
+ Sign_and_Submit() {
+ // bondedValue、ControllerValue、PayeeValue 和密码都输入了
+ // All of bondedValue、ControllerValue、PayeeValue and password has been entered
+ if (this.state.bondedValue && this.state.password && this.state.ControllerValue && this.state.PayeeValue) {
+ const _this = this
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ _this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const controller = _this.state.ControllerValue
+ const value = _this.state.bondedValue
+ const payee = _this.state.PayeeValue
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ let transfer
+ try {
+ transfer = await polkadotAPI.bond(controller, Number(value) * Number(_this.state.multiple), Number(payee))
+ } catch (e) {
+ _this.setState({
+ isModal: false,
+ onlyone: 0,
+ Failed: true
+ })
+ Alert.alert('', i18n.t('Staking.BondFailed'))
+ }
+ transfer.signAndSend(loadPair, ({ status }) => {
+ status = formatData(status)
+ if (status.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success',
+ Failed: false
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Staking.BondSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ } else {
+ Alert.alert('', i18n.t('TAB.enterInformation'))
+ }
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+
+ {i18n.t('Staking.BondFunds')}
+
+ {i18n.t('TAB.signMess')}
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+
+
+ {i18n.t('Staking.calling')}
+
+ staking.bondExtra
+
+
+
+
+ {i18n.t('Staking.Controller')}
+
+
+
+
+
+
+ {i18n.t('Staking.payee')}
+
+
+ this.setState({ PayeeValue: String(value) })}
+ data={[
+ {
+ title: 'Stash account (increase the amount at stake)',
+ value: '0'
+ },
+ {
+ title: 'Stash account (do not increase the amount at stake)',
+ value: '1'
+ },
+ {
+ title: 'Controller account',
+ value: '2'
+ }
+ ]}
+ />
+
+
+
+ {i18n.t('Staking.valueBonded')}
+
+
+
+
+
+
+
+
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Reset or Bond */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+
+ {i18n.t('Staking.BondFunds')}
+
+ ) : (
+
+ {i18n.t('Staking.BondFunds')}
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ middle: {
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ chooses: {
+ paddingLeft: ScreenWidth / 20,
+ paddingRight: ScreenWidth / 20,
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ flexDirection: 'row',
+ height: ScreenHeight / 18,
+ backgroundColor: '#DCDCDC'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+
+ choose_Text: {
+ fontWeight: '500',
+ fontSize: ScreenHeight / 50,
+ color: '#4169E1'
+ },
+ submit_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 1.3,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ Choose_way: {
+ alignItems: 'center',
+ marginLeft: ScreenWidth / 70,
+ width: ScreenWidth * 0.25,
+ height: ScreenHeight / 23,
+ borderWidth: 1,
+ borderRadius: ScreenHeight / 200,
+ borderColor: '#4dabd0',
+ flexDirection: 'row',
+ backgroundColor: '#4dabd0'
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ },
+ choessText: {
+ fontWeight: '500',
+ fontSize: ScreenWidth / 28,
+ color: 'white'
+ }
+})
+export default BondFunds
diff --git a/src/page/Staking/secondary/Nominate.js b/src/page/Staking/secondary/Nominate.js
index 966aae5f..382c2fd0 100755
--- a/src/page/Staking/secondary/Nominate.js
+++ b/src/page/Staking/secondary/Nominate.js
@@ -1,445 +1,463 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 22:22:06
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- Modal,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { ScreenWidth, ScreenHeight, formatData, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Nominate extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- address: this.props.navigation.state.params.address,
- password: '',
- isModal: false,
- onlyone: 0,
- type: 'pending...',
- Failed: false
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.onChangeAddress = this.onChangeAddress.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Nominate = this.Nominate.bind(this)
- }
-
- // 密码展示
- // Display password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // 改变地址
- // Change address
- onChangeAddress(ChangeAddress) {
- this.setState({
- address: String(ChangeAddress)
- })
- }
-
- // 密码修改
- // Change password
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 页面初始化
- // Page initialization
- componentWillMount() {
- ;(async () => {
- const accountNonce = await polkadotAPI.accountNonce(
- this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
- )
- this.setState({
- accountNonce: JSON.stringify(accountNonce)
- })
- })()
- }
-
- // 提交
- // Submit
- Nominate() {
- this.setState({
- onlyone: 1,
- isModal: true
- })
- const _this = this
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- let stash = await polkadotAPI.accountInfo(
- _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address
- )
- stash = formatData(stash).stakingLedger.stash
- let target
- if (stash) {
- target = await polkadotAPI.nominators(String(stash))
- target = formatData(target)
- target = target[0]
- } else {
- target = []
- }
- target = [...target, ...String(_this.state.address).split(',')]
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- let transfer
- try {
- transfer = await polkadotAPI.nominate(target)
- } catch (e) {
- _this.setState({
- isModal: false,
- onlyone: 0,
- Failed: true
- })
- Alert.alert('', i18n.t('Staking.NominateFailed'))
- }
- transfer.signAndSend(loadPair, ({ status }) => {
- status = formatData(status)
-
- if (status.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success',
- Failed: false
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Staking.NominateSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
- {i18n.t('Staking.NominateValidator')}
-
- {i18n.t('Staking.nominateAddress')}
- {i18n.t('Staking.multipleAddresses')}
-
-
-
-
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
-
- {/* Cancel or nominate */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
- {i18n.t('Staking.Nominate')}
-
- ) : (
-
- {i18n.t('Staking.Nominate')}
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- nominate_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 2,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- },
- choessText: {
- fontWeight: '500',
- fontSize: ScreenWidth / 28,
- color: 'white'
- }
-})
-export default Nominate
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ Modal,
+ Alert,
+ StatusBar,
+ SafeAreaView,
+ InteractionManager
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { ScreenWidth, ScreenHeight, formatData, checkPwd } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Nominate extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ address: this.props.navigation.state.params.address,
+ password: '',
+ isModal: false,
+ onlyone: 0,
+ type: 'pending...',
+ Failed: false
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.onChangeAddress = this.onChangeAddress.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Nominate = this.Nominate.bind(this)
+ }
+
+ /**
+ * @description 密码展示|Display password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 改变地址|Change address
+ * @param {String} ChangeAddress 地址
+ */
+ onChangeAddress(ChangeAddress) {
+ this.setState({
+ address: String(ChangeAddress)
+ })
+ }
+
+ /**
+ * @description 密码修改|Change password
+ * @param {String} Changepassword 密码
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 页面初始化|Page initialization
+ */
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ ;(async () => {
+ const accountNonce = await polkadotAPI.accountNonce(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ this.setState({
+ accountNonce: JSON.stringify(accountNonce)
+ })
+ })()
+ })
+ }
+
+ /**
+ * @description 提交|Submit
+ */
+ Nominate() {
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const _this = this
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ let stash = await polkadotAPI.accountInfo(
+ _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address
+ )
+ stash = formatData(stash).stakingLedger.stash
+ let target
+ if (stash) {
+ target = await polkadotAPI.nominators(String(stash))
+ target = formatData(target)
+ target = target[0]
+ } else {
+ target = []
+ }
+ target = [...target, ...String(_this.state.address).split(',')]
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ let transfer
+ try {
+ transfer = await polkadotAPI.nominate(target)
+ } catch (e) {
+ _this.setState({
+ isModal: false,
+ onlyone: 0,
+ Failed: true
+ })
+ Alert.alert('', i18n.t('Staking.NominateFailed'))
+ }
+ transfer.signAndSend(loadPair, ({ status }) => {
+ status = formatData(status)
+
+ if (status.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success',
+ Failed: false
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Staking.NominateSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+ {i18n.t('Staking.NominateValidator')}
+
+ {i18n.t('Staking.nominateAddress')}
+ {i18n.t('Staking.multipleAddresses')}
+
+
+
+
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+
+ {/* Cancel or nominate */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+
+ {i18n.t('Staking.Nominate')}
+
+ ) : (
+
+ {i18n.t('Staking.Nominate')}
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ nominate_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 2,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ },
+ choessText: {
+ fontWeight: '500',
+ fontSize: ScreenWidth / 28,
+ color: 'white'
+ }
+})
+export default Nominate
diff --git a/src/page/Staking/secondary/SetSessionKey.js b/src/page/Staking/secondary/SetSessionKey.js
index ca463972..1384c510 100755
--- a/src/page/Staking/secondary/SetSessionKey.js
+++ b/src/page/Staking/secondary/SetSessionKey.js
@@ -1,506 +1,520 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 22:22:06
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- Modal,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { formatData, ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class SetSessionKey extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- password: '',
- isModal: false,
- onlyone: 0,
- type: 'pending...',
- SessionKey: '',
- Failed: false
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
- }
-
- // 更改密码
- // Change password
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- // 展示密码
- // Show password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // SessionKey 改变
- onChangeValue(SessionKey) {
- this.setState({
- SessionKey: SessionKey
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 点击提交
- // Submit
- Sign_and_Submit() {
- if (this.state.SessionKey && this.state.password) {
- this.setState({
- onlyone: 1,
- isModal: true
- })
- const _this = this
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- _this.setState({
- onlyone: 1,
- isModal: true
- })
- const SessionKey = _this.state.SessionKey
- // 设置SessionKey为用户填写的
- // Set SessionKey to be filled by the user
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- let transfer
- try {
- transfer = await polkadotAPI.setKey(SessionKey)
- } catch (e) {
- this.setState({
- isModal: false,
- onlyone: 0,
- Failed: true
- })
- Alert.alert('', i18n.t('Staking.SessionKeyFailed'))
- }
- transfer.signAndSend(loadPair, ({ status }) => {
- status = formatData(status)
- if (status.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success',
- Failed: false
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Staking.SessionKeySuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- } else {
- Alert.alert('', i18n.t('TAB.enterInformation'))
- }
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
- {i18n.t('Staking.setSessionKey')}
-
- {i18n.t('TAB.signMess')}
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
-
-
- {i18n.t('Staking.calling')}
-
- session.setKey
-
-
-
- {i18n.t('Staking.SessionKey')}
-
-
-
-
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Cancel or Set */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
- {i18n.t('Staking.Set')}
-
- ) : (
-
- {i18n.t('Staking.Set')}
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- middle: {
- justifyContent: 'center',
- alignItems: 'center'
- },
- chooses: {
- paddingLeft: ScreenWidth / 20,
- paddingRight: ScreenWidth / 20,
- alignItems: 'center',
- justifyContent: 'space-between',
- flexDirection: 'row',
- height: ScreenHeight / 18,
- backgroundColor: '#DCDCDC'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
-
- choose_Text: {
- fontWeight: '500',
- fontSize: ScreenHeight / 50,
- color: '#4169E1'
- },
- submit_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 2,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- pwdInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.9,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- Choose_way: {
- alignItems: 'center',
- marginLeft: ScreenWidth / 70,
- width: ScreenWidth * 0.25,
- height: ScreenHeight / 23,
- borderWidth: 1,
- borderRadius: ScreenHeight / 200,
- borderColor: '#4dabd0',
- flexDirection: 'row',
- backgroundColor: '#4dabd0'
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- },
- choessText: {
- fontWeight: '500',
- fontSize: ScreenWidth / 28,
- color: 'white'
- }
-})
-export default SetSessionKey
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ Modal,
+ Alert,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { formatData, ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class SetSessionKey extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ password: '',
+ isModal: false,
+ onlyone: 0,
+ type: 'pending...',
+ SessionKey: '',
+ Failed: false
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
+ }
+
+ /**
+ * @description 更改密码|Change password
+ * @param {String} Changepassword 密码|password
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description 展示密码|Show password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description SessionKey change
+ * @param {String} SessionKey
+ */
+ onChangeValue(SessionKey) {
+ this.setState({
+ SessionKey: SessionKey
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 点击提交|Submit
+ */
+ Sign_and_Submit() {
+ if (this.state.SessionKey && this.state.password) {
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const _this = this
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ _this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const SessionKey = _this.state.SessionKey
+ // 设置SessionKey为用户填写的
+ // Set SessionKey to be filled by the user
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ let transfer
+ try {
+ transfer = await polkadotAPI.setKey(SessionKey)
+ } catch (e) {
+ this.setState({
+ isModal: false,
+ onlyone: 0,
+ Failed: true
+ })
+ Alert.alert('', i18n.t('Staking.SessionKeyFailed'))
+ }
+ transfer.signAndSend(loadPair, ({ status }) => {
+ status = formatData(status)
+ if (status.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success',
+ Failed: false
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Staking.SessionKeySuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ } else {
+ Alert.alert('', i18n.t('TAB.enterInformation'))
+ }
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+ {i18n.t('Staking.setSessionKey')}
+
+ {i18n.t('TAB.signMess')}
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+
+
+ {i18n.t('Staking.calling')}
+
+ session.setKey
+
+
+
+ {i18n.t('Staking.SessionKey')}
+
+
+
+
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Cancel or Set */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+
+ {i18n.t('Staking.Set')}
+
+ ) : (
+
+ {i18n.t('Staking.Set')}
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ middle: {
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ chooses: {
+ paddingLeft: ScreenWidth / 20,
+ paddingRight: ScreenWidth / 20,
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ flexDirection: 'row',
+ height: ScreenHeight / 18,
+ backgroundColor: '#DCDCDC'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+
+ choose_Text: {
+ fontWeight: '500',
+ fontSize: ScreenHeight / 50,
+ color: '#4169E1'
+ },
+ submit_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 2,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ pwdInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.9,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ Choose_way: {
+ alignItems: 'center',
+ marginLeft: ScreenWidth / 70,
+ width: ScreenWidth * 0.25,
+ height: ScreenHeight / 23,
+ borderWidth: 1,
+ borderRadius: ScreenHeight / 200,
+ borderColor: '#4dabd0',
+ flexDirection: 'row',
+ backgroundColor: '#4dabd0'
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ },
+ choessText: {
+ fontWeight: '500',
+ fontSize: ScreenWidth / 28,
+ color: 'white'
+ }
+})
+export default SetSessionKey
diff --git a/src/page/Staking/secondary/Stake.js b/src/page/Staking/secondary/Stake.js
index ec235835..847ed1c0 100755
--- a/src/page/Staking/secondary/Stake.js
+++ b/src/page/Staking/secondary/Stake.js
@@ -1,582 +1,598 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 22:22:06
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- Modal,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { getUnit, formatData, ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-import RNPicker from '../../../components/RNPicker'
-
-@inject('rootStore')
-@observer
-class Stake extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- password: '',
- isModal: false,
- isWayModel: false,
- way: 'DOT',
- onlyone: 0,
- type: 'pending...',
- way_change: 'DOT',
- multiple: 1000000000000000,
- unstakeThreshold: '',
- validatorPayment: '',
- Failed: false
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
- this.Modify_way = this.Modify_way.bind(this)
- }
-
- // 展示密码
- // Show password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // 更改单位
- // Switch units
- Modify_way(way_change) {
- this.setState({
- isWayModel: false,
- way_change: way_change,
- way: way_change,
- multiple: getUnit(way_change)
- })
- }
-
- // 更改密码
- // Change password
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- // unstakeThreshold changed
- onChangeUnstakeThreshold(unstakeThreshold) {
- this.setState({
- unstakeThreshold
- })
- }
-
- // validatorPayment changed
- onChangeValidatorPayment(validatorPayment) {
- this.setState({
- validatorPayment: validatorPayment
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 提交
- // Submit
- Sign_and_Submit() {
- if (this.state.unstakeThreshold && this.state.validatorPayment && this.state.password) {
- const _this = this
- this.setState({
- onlyone: 1,
- isModal: true
- })
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- _this.setState({
- onlyone: 1,
- isModal: true
- })
- const preferences = {
- unstakeThreshold: _this.state.unstakeThreshold,
- validatorPayment: Number(_this.state.validatorPayment) * Number(_this.state.multiple)
- }
- console.log(preferences)
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- let transfer
- try {
- transfer = await polkadotAPI.validate(preferences)
- } catch (e) {
- _this.setState({
- isModal: false,
- onlyone: 0,
- Failed: true
- })
- Alert.alert('', i18n.t('Staking.ValidateFailed'))
- }
- transfer.signAndSend(loadPair, ({ status }) => {
- let state = formatData(status)
- console.log(state)
- if (state.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success',
- Failed: false
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Staking.ValidateSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- console.log('error')
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- } else {
- Alert.alert('', i18n.t('TAB.enterInformation'))
- }
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
- {i18n.t('Staking.Validate')}
-
- {i18n.t('TAB.signMess')}
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
-
-
- {i18n.t('Staking.calling')}
-
- staking.validate
-
-
-
-
- {i18n.t('Staking.unstakeThreshold')}
-
-
-
-
-
-
- {i18n.t('Staking.validatorPayment')}
-
-
-
-
-
-
-
-
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Cancel or Validate */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
- {i18n.t('Staking.Validate')}
-
- ) : (
-
- {i18n.t('Staking.Validate')}
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- middle: {
- justifyContent: 'center',
- alignItems: 'center'
- },
- chooses: {
- paddingLeft: ScreenWidth / 20,
- paddingRight: ScreenWidth / 20,
- alignItems: 'center',
- justifyContent: 'space-between',
- flexDirection: 'row',
- height: ScreenHeight / 18,
- backgroundColor: '#DCDCDC'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
-
- choose_Text: {
- fontWeight: '500',
- fontSize: ScreenHeight / 50,
- color: '#4169E1'
- },
- submit_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 1.5,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- Choose_way: {
- alignItems: 'center',
- marginLeft: ScreenWidth / 70,
- width: ScreenWidth * 0.25,
- height: ScreenHeight / 23,
- borderWidth: 1,
- borderRadius: ScreenHeight / 200,
- borderColor: '#4dabd0',
- flexDirection: 'row',
- backgroundColor: '#4dabd0'
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- },
- choessText: {
- fontWeight: '500',
- fontSize: ScreenWidth / 28,
- color: 'white'
- }
-})
-export default Stake
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ Modal,
+ Alert,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { getUnit, formatData, ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+import RNPicker from '../../../components/RNPicker'
+
+@inject('rootStore')
+@observer
+class Stake extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ password: '',
+ isModal: false,
+ isWayModel: false,
+ way: 'DOT',
+ onlyone: 0,
+ type: 'pending...',
+ way_change: 'DOT',
+ multiple: 1000000000000000,
+ unstakeThreshold: '',
+ validatorPayment: '',
+ Failed: false
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
+ this.Modify_way = this.Modify_way.bind(this)
+ }
+
+ /**
+ * @description 展示密码|Show password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 更改单位|Switch units
+ * @param {String} way_change 单位|Units
+ */
+ Modify_way(way_change) {
+ this.setState({
+ isWayModel: false,
+ way_change: way_change,
+ way: way_change,
+ multiple: getUnit(way_change)
+ })
+ }
+
+ /**
+ * @description 更改密码|Change password
+ * @param {String} Changepassword 密码|Password
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description unstakeThreshold更改|unstakeThreshold changed
+ * @param {String} unstakeThreshold The value of unstakeThreshold
+ */
+ onChangeUnstakeThreshold(unstakeThreshold) {
+ this.setState({
+ unstakeThreshold
+ })
+ }
+
+ /**
+ * @description alidatorPayment 更改 | alidatorPayment changed
+ * @param {String} validatorPayment The value of validatorPayment
+ */
+ onChangeValidatorPayment(validatorPayment) {
+ this.setState({
+ validatorPayment: validatorPayment
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 提交|Submit
+ */
+ Sign_and_Submit() {
+ if (this.state.unstakeThreshold && this.state.validatorPayment && this.state.password) {
+ const _this = this
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ _this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const preferences = {
+ unstakeThreshold: _this.state.unstakeThreshold,
+ validatorPayment: Number(_this.state.validatorPayment) * Number(_this.state.multiple)
+ }
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ let transfer
+ try {
+ transfer = await polkadotAPI.validate(preferences)
+ } catch (e) {
+ _this.setState({
+ isModal: false,
+ onlyone: 0,
+ Failed: true
+ })
+ Alert.alert('', i18n.t('Staking.ValidateFailed'))
+ }
+ transfer.signAndSend(loadPair, ({ status }) => {
+ let state = formatData(status)
+ if (state.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success',
+ Failed: false
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Staking.ValidateSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ } else {
+ Alert.alert('', i18n.t('TAB.enterInformation'))
+ }
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+ {i18n.t('Staking.Validate')}
+
+ {i18n.t('TAB.signMess')}
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+
+
+ {i18n.t('Staking.calling')}
+
+ staking.validate
+
+
+
+
+ {i18n.t('Staking.unstakeThreshold')}
+
+
+
+
+
+
+ {i18n.t('Staking.validatorPayment')}
+
+
+
+
+
+
+
+
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Cancel or Validate */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+
+ {i18n.t('Staking.Validate')}
+
+ ) : (
+
+ {i18n.t('Staking.Validate')}
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ middle: {
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ chooses: {
+ paddingLeft: ScreenWidth / 20,
+ paddingRight: ScreenWidth / 20,
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ flexDirection: 'row',
+ height: ScreenHeight / 18,
+ backgroundColor: '#DCDCDC'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+
+ choose_Text: {
+ fontWeight: '500',
+ fontSize: ScreenHeight / 50,
+ color: '#4169E1'
+ },
+ submit_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 1.5,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ Choose_way: {
+ alignItems: 'center',
+ marginLeft: ScreenWidth / 70,
+ width: ScreenWidth * 0.25,
+ height: ScreenHeight / 23,
+ borderWidth: 1,
+ borderRadius: ScreenHeight / 200,
+ borderColor: '#4dabd0',
+ flexDirection: 'row',
+ backgroundColor: '#4dabd0'
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ },
+ choessText: {
+ fontWeight: '500',
+ fontSize: ScreenWidth / 28,
+ color: 'white'
+ }
+})
+export default Stake
diff --git a/src/page/Staking/secondary/Unbond.js b/src/page/Staking/secondary/Unbond.js
index d50ab002..93e6ccd4 100755
--- a/src/page/Staking/secondary/Unbond.js
+++ b/src/page/Staking/secondary/Unbond.js
@@ -1,539 +1,555 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 22:22:06
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- Modal,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { getUnit, ScreenWidth, ScreenHeight, formatData, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-import RNPicker from '../../../components/RNPicker'
-
-@inject('rootStore')
-@observer
-class Unbond extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- password: '',
- isModal: false,
- isWayModel: false,
- way: 'DOT',
- onlyone: 0,
- type: 'pending...',
- way_change: 'DOT',
- multiple: 1000000000000000,
- bondedValue: '',
- Failed: false
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
- this.Modify_way = this.Modify_way.bind(this)
- }
-
- // 更改密码
- // Change password
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- // 展示密码
- // Show password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // 更改单位
- // Change units
- Modify_way(way_change) {
- this.setState({
- isWayModel: false,
- way_change: way_change,
- way: way_change,
- multiple: getUnit(way_change)
- })
- }
-
- // bondedValue changed
- onChangeValue(bondedValue) {
- this.setState({
- bondedValue: bondedValue
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 点击提交
- // Submit
- Sign_and_Submit() {
- if (this.state.bondedValue && this.state.password) {
- this.setState({
- onlyone: 1,
- isModal: true
- })
- const _this = this
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- _this.setState({
- onlyone: 1,
- isModal: true
- })
- const value = _this.state.bondedValue
-
- let transfer
- try {
- transfer = await polkadotAPI.unbond(Number(value) * Number(_this.state.multiple))
- } catch (e) {
- _this.setState({
- isModal: false,
- onlyone: 0,
- Failed: true
- })
- Alert.alert('', i18n.t('Staking.UnbondFailed'))
- }
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
-
- transfer.signAndSend(loadPair, ({ status }) => {
- status = formatData(status)
- if (status.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success',
- Failed: false
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Staking.UnbondSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- } else {
- Alert.alert('', i18n.t('TAB.enterInformation'))
- }
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
- {i18n.t('Staking.UnBond')}
-
- {i18n.t('TAB.signMess')}
-
-
- {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
-
-
-
- {i18n.t('Staking.calling')}
-
- staking.unbond
-
-
-
- {i18n.t('Staking.unbondAmount')}
-
-
-
-
-
-
-
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Cancel or UnBond */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
- {i18n.t('Staking.UnBond')}
-
- ) : (
-
- {i18n.t('Staking.UnBond')}
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- middle: {
- justifyContent: 'center',
- alignItems: 'center'
- },
- chooses: {
- paddingLeft: ScreenWidth / 20,
- paddingRight: ScreenWidth / 20,
- alignItems: 'center',
- justifyContent: 'space-between',
- flexDirection: 'row',
- height: ScreenHeight / 18,
- backgroundColor: '#DCDCDC'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
-
- choose_Text: {
- fontWeight: '500',
- fontSize: ScreenHeight / 50,
- color: '#4169E1'
- },
- submit_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 2,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- Choose_way: {
- alignItems: 'center',
- marginLeft: ScreenWidth / 70,
- width: ScreenWidth * 0.25,
- height: ScreenHeight / 23,
- borderWidth: 1,
- borderRadius: ScreenHeight / 200,
- borderColor: '#4dabd0',
- flexDirection: 'row',
- backgroundColor: '#4dabd0'
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- },
- choessText: {
- fontWeight: '500',
- fontSize: ScreenWidth / 28,
- color: 'white'
- }
-})
-export default Unbond
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ Modal,
+ Alert,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { getUnit, ScreenWidth, ScreenHeight, formatData, checkPwd } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+import RNPicker from '../../../components/RNPicker'
+
+@inject('rootStore')
+@observer
+class Unbond extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ password: '',
+ isModal: false,
+ isWayModel: false,
+ way: 'DOT',
+ onlyone: 0,
+ type: 'pending...',
+ way_change: 'DOT',
+ multiple: 1000000000000000,
+ bondedValue: '',
+ Failed: false
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Sign_and_Submit = this.Sign_and_Submit.bind(this)
+ this.Modify_way = this.Modify_way.bind(this)
+ }
+
+ /**
+ * @description 更改密码|Change password
+ * @param {String} Changepassword 密码|password
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description 展示密码|Show password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 更改单位|Change units
+ * @param {String} way_change 单位|Units
+ */
+ Modify_way(way_change) {
+ this.setState({
+ isWayModel: false,
+ way_change: way_change,
+ way: way_change,
+ multiple: getUnit(way_change)
+ })
+ }
+
+ /**
+ * @description bonded 更改 | bondedValue changed
+ * @param {*} bondedValue 更改的值
+ */
+ onChangeValue(bondedValue) {
+ this.setState({
+ bondedValue: bondedValue
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 点击提交|Submit
+ */
+ Sign_and_Submit() {
+ if (this.state.bondedValue && this.state.password) {
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const _this = this
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ _this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const value = _this.state.bondedValue
+
+ let transfer
+ try {
+ transfer = await polkadotAPI.unbond(Number(value) * Number(_this.state.multiple))
+ } catch (e) {
+ _this.setState({
+ isModal: false,
+ onlyone: 0,
+ Failed: true
+ })
+ Alert.alert('', i18n.t('Staking.UnbondFailed'))
+ }
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+
+ transfer.signAndSend(loadPair, ({ status }) => {
+ status = formatData(status)
+ if (status.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success',
+ Failed: false
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Staking.UnbondSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ } else {
+ Alert.alert('', i18n.t('TAB.enterInformation'))
+ }
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+ {i18n.t('Staking.UnBond')}
+
+ {i18n.t('TAB.signMess')}
+
+
+ {this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address}
+
+
+
+ {i18n.t('Staking.calling')}
+
+ staking.unbond
+
+
+
+ {i18n.t('Staking.unbondAmount')}
+
+
+
+
+
+
+
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Cancel or UnBond */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+
+ {i18n.t('Staking.UnBond')}
+
+ ) : (
+
+ {i18n.t('Staking.UnBond')}
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ middle: {
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ chooses: {
+ paddingLeft: ScreenWidth / 20,
+ paddingRight: ScreenWidth / 20,
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ flexDirection: 'row',
+ height: ScreenHeight / 18,
+ backgroundColor: '#DCDCDC'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+
+ choose_Text: {
+ fontWeight: '500',
+ fontSize: ScreenHeight / 50,
+ color: '#4169E1'
+ },
+ submit_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 2,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ Choose_way: {
+ alignItems: 'center',
+ marginLeft: ScreenWidth / 70,
+ width: ScreenWidth * 0.25,
+ height: ScreenHeight / 23,
+ borderWidth: 1,
+ borderRadius: ScreenHeight / 200,
+ borderColor: '#4dabd0',
+ flexDirection: 'row',
+ backgroundColor: '#4dabd0'
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ },
+ choessText: {
+ fontWeight: '500',
+ fontSize: ScreenWidth / 28,
+ color: 'white'
+ }
+})
+export default Unbond
diff --git a/src/page/Staking/secondary/Unnominate.js b/src/page/Staking/secondary/Unnominate.js
index a8072b58..50a92457 100755
--- a/src/page/Staking/secondary/Unnominate.js
+++ b/src/page/Staking/secondary/Unnominate.js
@@ -1,395 +1,402 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 22:22:06
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- Modal,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { formatData, ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import polkadotAPI from '../../../util/polkadotAPI'
-import i18n from '../../../locales/i18n'
-
-@inject('rootStore')
-@observer
-class Unnominate extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- address: '',
- password: '',
- isModal: false,
- onlyone: 0,
- type: 'pending...',
- Failed: false
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.onChangeAddress = this.onChangeAddress.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Unnominate = this.Unnominate.bind(this)
- }
-
- // 展示密码
- // Show password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // 选择通讯录
- // Switch addresses
- onChangeAddress(ChangeAddress) {
- this.setState({
- address: ChangeAddress
- })
- }
-
- // 更改密码
- // Change password
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 点击提交
- // Submit
- Unnominate() {
- const _this = this
- this.setState({
- onlyone: 1,
- isModal: true
- })
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- let transfer
- try {
- transfer = await polkadotAPI.chill()
- } catch (e) {
- _this.setState({
- isModal: false,
- onlyone: 0,
- Failed: true
- })
- Alert.alert('', i18n.t('Staking.UnnominateFailed'))
- }
- transfer.signAndSend(loadPair, ({ status }) => {
- status = formatData(status)
- // 成功
- if (status.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success',
- Failed: false
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Staking.UnnominateSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
- staking.chill
-
- {i18n.t('Staking.nominateTip')}
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Cancel or UnBond */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
- {i18n.t('Staking.Unnominate')}
-
- ) : (
-
- {i18n.t('Staking.Unnominate')}
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- nominate_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 2,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- }
-})
-export default Unnominate
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ Modal,
+ Alert,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { formatData, ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import polkadotAPI from '../../../util/polkadotAPI'
+import i18n from '../../../locales/i18n'
+
+@inject('rootStore')
+@observer
+class Unnominate extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ address: '',
+ password: '',
+ isModal: false,
+ onlyone: 0,
+ type: 'pending...',
+ Failed: false
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.onChangeAddress = this.onChangeAddress.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Unnominate = this.Unnominate.bind(this)
+ }
+
+ /**
+ * @description 展示密码|Show password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 更改地址 | change address
+ * @param {String} ChangeAddress 地址|Address
+ */
+ onChangeAddress(ChangeAddress) {
+ this.setState({
+ address: ChangeAddress
+ })
+ }
+
+ /**
+ * @description 更改密码|Change password
+ * @param {String} Changepassword 密码
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 点击提交|Submit
+ */
+ Unnominate() {
+ const _this = this
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ let transfer
+ try {
+ transfer = await polkadotAPI.chill()
+ } catch (e) {
+ _this.setState({
+ isModal: false,
+ onlyone: 0,
+ Failed: true
+ })
+ Alert.alert('', i18n.t('Staking.UnnominateFailed'))
+ }
+ transfer.signAndSend(loadPair, ({ status }) => {
+ status = formatData(status)
+ // 成功
+ if (status.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success',
+ Failed: false
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Staking.UnnominateSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+ staking.chill
+
+ {i18n.t('Staking.nominateTip')}
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Cancel or UnBond */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+
+ {i18n.t('Staking.Unnominate')}
+
+ ) : (
+
+ {i18n.t('Staking.Unnominate')}
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ nominate_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 2,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ }
+})
+export default Unnominate
diff --git a/src/page/Staking/secondary/Unstake.js b/src/page/Staking/secondary/Unstake.js
index 8512b89c..39ced2cf 100755
--- a/src/page/Staking/secondary/Unstake.js
+++ b/src/page/Staking/secondary/Unstake.js
@@ -1,397 +1,410 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 22:22:06
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- View,
- TextInput,
- Text,
- TouchableOpacity,
- Image,
- Modal,
- Alert,
- StatusBar,
- SafeAreaView
-} from 'react-native'
-import { observer, inject } from 'mobx-react'
-import { formatData, ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
-import Header from '../../../components/Header'
-import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
-import i18n from '../../../locales/i18n'
-import polkadotAPI from '../../../util/polkadotAPI'
-
-@inject('rootStore')
-@observer
-class Unstake extends Component {
- constructor(props) {
- super(props)
- this.state = {
- ispwd: true,
- address: '',
- password: '',
- isModal: false,
- onlyone: 0,
- type: 'pending...',
- Failed: false
- }
- this.lookpwd = this.lookpwd.bind(this)
- this.onChangepassword = this.onChangepassword.bind(this)
- this.onChangeAddress = this.onChangeAddress.bind(this)
- this.Cancel = this.Cancel.bind(this)
- this.Unstake = this.Unstake.bind(this)
- }
-
- // 密码的展示
- // Display password
- lookpwd() {
- this.setState({
- ispwd: !this.state.ispwd
- })
- }
-
- // 通讯录选择
- // Switch Addresses
- onChangeAddress(ChangeAddress) {
- this.setState({
- address: ChangeAddress
- })
- }
-
- // 密码更改
- // Change password
- onChangepassword(Changepassword) {
- this.setState({
- password: Changepassword
- })
- }
-
- // 点击取消
- // Click Cancel
- Cancel() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 点击提交
- // Submit
- Unstake() {
- this.setState({
- onlyone: 1,
- isModal: true
- })
- const _this = this
- checkPwd({
- address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
- password: _this.state.password,
- success: loadPair => {
- ;(async () => {
- setTimeout(() => {
- if (_this.state.type == 'pending...') {
- Alert.alert(
- '',
- i18n.t('TAB.noResponse'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false,
- onlyone: 0
- })
- }
- }
- ],
- { cancelable: false }
- )
- }
- }, 30000)
- let transfer
- try {
- transfer = await polkadotAPI.chill()
- } catch (e) {
- _this.setState({
- isModal: false,
- onlyone: 0,
- Failed: true
- })
- Alert.alert('', i18n.t('Staking.UnvalidateFailed'))
- }
- transfer.signAndSend(loadPair, ({ status }) => {
- status = formatData(status)
- if (status.Finalized) {
- _this.setState({
- isModal: false,
- type: 'success',
- Failed: false
- })
- setTimeout(() => {
- Alert.alert(
- '',
- i18n.t('Staking.UnvalidateSuccess'),
- [
- {
- text: 'OK',
- onPress: () => {
- _this.setState({
- isModal: false
- })
- _this.props.navigation.navigate('Tabbed_Navigation')
- }
- }
- ],
- { cancelable: false }
- )
- }, 500)
- } else {
- _this.setState({
- type: 'pending...'
- })
- }
- })
- })()
- },
- error: () => {
- _this.setState({
- onlyone: 0,
- isModal: false
- })
- }
- })
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
-
- staking.chill
-
- {i18n.t('Staking.UnvalidateTip')}
-
- {i18n.t('TAB.unlockPassword')}
-
-
-
-
-
-
-
-
-
- {/* Cancel or UnBond */}
-
-
-
- {i18n.t('TAB.Cancel')}
-
- {this.state.onlyone == 0 ? (
-
- {i18n.t('Staking.Unvalidate')}
-
- ) : (
-
- {i18n.t('Staking.Unvalidate')}
-
- )}
-
-
-
-
-
-
-
- {this.state.type}
-
-
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: 'white'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'center',
- backgroundColor: '#776f71'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: '#e6e6e6'
- },
- nominate_view: {
- marginTop: ScreenHeight / 15,
- alignSelf: 'center',
- height: ScreenHeight / 2,
- borderWidth: 1,
- width: ScreenWidth * 0.98,
- borderRadius: ScreenHeight / 100,
- borderColor: 'grey',
- paddingLeft: ScreenWidth / 40
- },
- title_b: {
- color: 'black',
- fontSize: ScreenHeight / 40,
- marginTop: ScreenHeight / 50,
- fontWeight: '500'
- },
- grey_text: {
- backgroundColor: '#F0EFEF',
- height: ScreenHeight / 25,
- justifyContent: 'center',
- alignItems: 'center'
- },
- grey_t: {
- marginHorizontal: ScreenWidth * 0.02,
- color: 'black',
- fontSize: ScreenHeight / 50,
- fontWeight: '500'
- },
- textInputStyle: {
- paddingVertical: 0,
- height: ScreenHeight / 23,
- width: ScreenWidth * 0.65,
- borderWidth: 1,
- borderColor: '#97BEC7',
- borderRadius: ScreenHeight / 200,
- paddingLeft: ScreenHeight / 100
- },
- image: {
- height: ScreenHeight / 38,
- width: ScreenHeight / 38,
- resizeMode: 'contain'
- },
- eye: {
- height: ScreenHeight / 23,
- width: ScreenHeight / 23,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#97BEC7'
- }
-})
-export default Unstake
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ View,
+ TextInput,
+ Text,
+ TouchableOpacity,
+ Image,
+ Modal,
+ Alert,
+ StatusBar,
+ SafeAreaView
+} from 'react-native'
+import { observer, inject } from 'mobx-react'
+import { formatData, ScreenWidth, ScreenHeight, checkPwd } from '../../../util/Common'
+import Header from '../../../components/Header'
+import RNKeyboardAvoidView from '../../../components/RNKeyboardAvoidView'
+import i18n from '../../../locales/i18n'
+import polkadotAPI from '../../../util/polkadotAPI'
+
+@inject('rootStore')
+@observer
+class Unstake extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ ispwd: true,
+ address: '',
+ password: '',
+ isModal: false,
+ onlyone: 0,
+ type: 'pending...',
+ Failed: false
+ }
+ this.lookpwd = this.lookpwd.bind(this)
+ this.onChangepassword = this.onChangepassword.bind(this)
+ this.onChangeAddress = this.onChangeAddress.bind(this)
+ this.Cancel = this.Cancel.bind(this)
+ this.Unstake = this.Unstake.bind(this)
+ }
+
+ /**
+ * @description 密码的展示|Display password
+ */
+ lookpwd() {
+ this.setState({
+ ispwd: !this.state.ispwd
+ })
+ }
+
+ /**
+ * @description 更改地址|change address
+ * @param {String} ChangeAddress 地址|Address
+ */
+ onChangeAddress(ChangeAddress) {
+ this.setState({
+ address: ChangeAddress
+ })
+ }
+
+ /**
+ * @description 密码更改|Change password
+ * @param {String} Changepassword 密码|Password
+ */
+ onChangepassword(Changepassword) {
+ this.setState({
+ password: Changepassword
+ })
+ }
+
+ /**
+ * @description 点击取消|Click Cancel
+ */
+ Cancel() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 点击提交|Submit
+ */
+ Unstake() {
+ this.setState({
+ onlyone: 1,
+ isModal: true
+ })
+ const _this = this
+ checkPwd({
+ address: _this.props.rootStore.stateStore.Accounts[_this.props.rootStore.stateStore.Account].address,
+ password: _this.state.password,
+ success: loadPair => {
+ ;(async () => {
+ setTimeout(() => {
+ if (_this.state.type == 'pending...') {
+ Alert.alert(
+ '',
+ i18n.t('TAB.noResponse'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false,
+ onlyone: 0
+ })
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ }, 15000)
+ let transfer
+ try {
+ transfer = await polkadotAPI.chill()
+ } catch (e) {
+ _this.setState({
+ isModal: false,
+ onlyone: 0,
+ Failed: true
+ })
+ Alert.alert('', i18n.t('Staking.UnvalidateFailed'))
+ }
+ transfer.signAndSend(loadPair, ({ status }) => {
+ status = formatData(status)
+ if (status.Finalized) {
+ _this.setState({
+ isModal: false,
+ type: 'success',
+ Failed: false
+ })
+ setTimeout(() => {
+ Alert.alert(
+ '',
+ i18n.t('Staking.UnvalidateSuccess'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ _this.setState({
+ isModal: false
+ })
+ _this.props.navigation.navigate('Tabbed_Navigation')
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }, 500)
+ } else {
+ _this.setState({
+ type: 'pending...'
+ })
+ }
+ })
+ })()
+ },
+ error: () => {
+ _this.setState({
+ onlyone: 0,
+ isModal: false
+ })
+ }
+ })
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+
+ staking.chill
+
+ {i18n.t('Staking.UnvalidateTip')}
+
+ {i18n.t('TAB.unlockPassword')}
+
+
+
+
+
+
+
+
+
+ {/* Cancel or UnBond */}
+
+
+
+ {i18n.t('TAB.Cancel')}
+
+ {this.state.onlyone == 0 ? (
+
+ {i18n.t('Staking.Unvalidate')}
+
+ ) : (
+
+ {i18n.t('Staking.Unvalidate')}
+
+ )}
+
+
+
+
+
+
+
+ {this.state.type}
+
+
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: 'white'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ backgroundColor: '#776f71'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: '#e6e6e6'
+ },
+ nominate_view: {
+ marginTop: ScreenHeight / 15,
+ alignSelf: 'center',
+ height: ScreenHeight / 2,
+ borderWidth: 1,
+ width: ScreenWidth * 0.98,
+ borderRadius: ScreenHeight / 100,
+ borderColor: 'grey',
+ paddingLeft: ScreenWidth / 40
+ },
+ title_b: {
+ color: 'black',
+ fontSize: ScreenHeight / 40,
+ marginTop: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ grey_text: {
+ backgroundColor: '#F0EFEF',
+ height: ScreenHeight / 25,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ grey_t: {
+ marginHorizontal: ScreenWidth * 0.02,
+ color: 'black',
+ fontSize: ScreenHeight / 50,
+ fontWeight: '500'
+ },
+ textInputStyle: {
+ paddingVertical: 0,
+ height: ScreenHeight / 23,
+ width: ScreenWidth * 0.65,
+ borderWidth: 1,
+ borderColor: '#97BEC7',
+ borderRadius: ScreenHeight / 200,
+ paddingLeft: ScreenHeight / 100
+ },
+ image: {
+ height: ScreenHeight / 38,
+ width: ScreenHeight / 38,
+ resizeMode: 'contain'
+ },
+ eye: {
+ height: ScreenHeight / 23,
+ width: ScreenHeight / 23,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#97BEC7'
+ }
+})
+export default Unstake
diff --git a/src/page/Staking/secondary/ValidatorInfo.js b/src/page/Staking/secondary/ValidatorInfo.js
index 987f5e14..a9c36823 100755
--- a/src/page/Staking/secondary/ValidatorInfo.js
+++ b/src/page/Staking/secondary/ValidatorInfo.js
@@ -1,615 +1,678 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import {
- StyleSheet,
- Text,
- View,
- TouchableOpacity,
- ScrollView,
- Image,
- StatusBar,
- Clipboard,
- SafeAreaView,
- Alert
-} from 'react-native'
-import Echarts from 'native-echarts'
-import Identicon from 'polkadot-identicon-react-native'
-import { formatBalance } from '@polkadot/util'
-import moment from 'moment/moment'
-import { observer, inject } from 'mobx-react'
-import Header from '../../../components/Header'
-import { formatData, ScreenWidth, ScreenHeight, axios } from '../../../util/Common'
-import i18n from '../../../locales/i18n'
-import polkadotAPI from '../../../util/polkadotAPI'
-
-@inject('rootStore')
-@observer
-class ValidatorInfo extends Component {
- constructor(props) {
- super(props)
- this.state = {
- address: this.props.navigation.state.params.address,
- titlebottomAA: 1,
- nominators: [],
- nominatorsBalance: [],
- validatorBalances: 0,
- StakingNextPage: false,
- StakingRecords: {},
- pageNum: 1,
- inNominators: false,
- StakingOption: {
- title: {
- text: i18n.t('Staking.StakingOption'),
- textStyle: {
- color: '#3E2D32',
- fontSize: 16
- },
- padding: [0, 0, 0, 0]
- },
- tooltip: {},
- legend: {
- data: ['']
- },
- grid: {
- left: 5
- },
- xAxis: {
- axisLine: {
- show: false
- },
- data: []
- },
- yAxis: {
- axisLine: {
- show: false
- },
- position: 'right'
- },
- color: ['#FF5080'],
- series: [
- {
- type: 'line',
- smooth: true,
- data: []
- }
- ]
- }
- }
- this.back = this.back.bind(this)
- this.nominate = this.nominate.bind(this)
- this.Unnominate = this.Unnominate.bind(this)
- this.copy = this.copy.bind(this)
- this.Loadmore = this.Loadmore.bind(this)
- }
-
- // 返回
- // Click back
- back() {
- this.props.navigation.navigate('Tabbed_Navigation')
- }
-
- // 进入Nominate页面
- // Enter the Nominate page
- nominate() {
- this.props.rootStore.stateStore.tonominate = 1
- this.props.navigation.navigate('Nominate', { address: this.state.address })
- }
-
- // 进入Unnominate页面
- // Enter the Unnominate page
- Unnominate() {
- this.props.navigation.navigate('Unnominate')
- }
-
- async copy() {
- Clipboard.setString(this.state.address)
- Alert.alert('', i18n.t('TAB.CopySuccess'))
- }
-
- // 加载更多
- // Load for more info
- Loadmore() {
- const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_list_alexander'
- const params = `{"user_address":"${this.state.address}","pageNum":"${this.state.pageNum}","pageSize":"10"}`
- axios(REQUEST_URL, params).then(result => {
- this.setState({
- StakingNextPage: result.staking_list_alexander.hasNextPage
- })
- const _StakingRecords = this.state.StakingRecords
- result.staking_list_alexander.list.map(item => {
- _StakingRecords.staking_list_alexander.list.push(item)
- })
- this.setState({
- StakingRecords: _StakingRecords
- })
- })
- }
-
- componentWillMount() {
- ;(async () => {
- // 获取选中账户的Staking Records
- // Get Staking Records for the selected account
- const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_list_alexander'
- const params = `{"user_address":"${this.state.address}","pageNum":"1","pageSize":"10"}`
- axios(REQUEST_URL, params)
- .then(result => {
- this.setState({
- StakingNextPage: result.staking_list_alexander.hasNextPage,
- StakingRecords: result
- })
- })
- .catch()
- const info = await polkadotAPI.accountInfo(this.state.address)
- const nominators = formatData(info).stakers.others
- this.setState({
- nominators,
- validatorBalances: formatData(info).stakers.own || formatData(info).stakingLedger.active
- })
- })()
- this.getStakingOption(this.props.navigation.state.params.address)
- }
-
- getStakingOption(address) {
- ;(async () => {
- // 获取选中账户staking折线图数据
- // Get the data of staking chart of the selected account
- const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_chart_alexander'
- const params = `{"user_address":"${String(address)}","UTCdate":"${moment(new Date().getTime()).format(
- 'YYYY-MM-DD HH:mm:ss'
- )}"}`
- axios(REQUEST_URL, params)
- .then(result => {
- const _StakingOption = {
- title: {
- text: i18n.t('Staking.StakingOption'),
- textStyle: {
- color: '#3E2D32',
- fontSize: 16
- },
- padding: [0, 0, 0, 0]
- },
- tooltip: {},
- legend: {
- data: ['']
- },
- grid: {
- left: 5
- },
- xAxis: {
- axisLine: {
- show: false
- },
- data: []
- },
- yAxis: {
- axisLine: {
- show: false
- },
- position: 'right'
- },
- color: ['#FF5080'],
- series: [
- {
- type: 'line',
- smooth: true,
- data: []
- }
- ]
- }
- result.map(item => {
- _StakingOption.xAxis.data.push(`${item.time.substring(5, 7)}/${item.time.substring(8, 10)}`)
- _StakingOption.series[0].data.push((item.slash_balance / 1000000).toFixed(1))
- })
- let max = 0
- for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
- if (_StakingOption.series[0].data[i] > max) {
- max = _StakingOption.series[0].data[i]
- }
- }
- const power =
- formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).power +
- formatBalance.getDefaults().decimals
- const unit = formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).text
- for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
- _StakingOption.series[0].data[i] = (_StakingOption.series[0].data[i] / Number(Math.pow(10, power))).toFixed(
- 3
- )
- }
- _StakingOption.title.text = `${i18n.t('Staking.stakingOption_new')}( ${unit} )`
- this.setState({
- StakingOption: _StakingOption
- })
- })
- .catch()
- })()
- }
-
- render() {
- return (
-
-
- {/* 标题栏 | Title bar */}
-
-
-
-
-
- {/* *********************** 点线图 *********************** */}
-
-
-
-
-
- {/* 头像 | Identicon */}
-
-
-
-
- {/* 地址 | Address */}
-
- {this.state.address}
-
- {/* 余额 | Balance */}
-
- {i18n.t('Staking.balance')}
- {` ${formatBalance(String(Number(this.state.validatorBalances)))}`}
-
-
-
-
-
-
- {this.state.inNominators ? i18n.t('Staking.Unnominate') : i18n.t('Staking.Nominate')}
-
-
-
-
-
- {
- this.setState({
- titlebottomAA: 1
- })
- }}
- >
-
-
- {i18n.t('Staking.Nominators')}
-
-
-
-
- {
- this.setState({
- titlebottomAA: 2
- })
- }}
- >
-
-
- {i18n.t('Staking.SlashRecords')}
-
-
-
-
-
- {this.state.titlebottomAA == 1 ? (
-
- {// Nominators
- this.state.nominators.length == 0 ? (
-
- {i18n.t('Staking.V_no_Nominator')}
-
- ) : (
- this.state.nominators.map((item, index) => (
-
-
-
-
- {formatData(item).who}
-
-
-
- {formatBalance(String(Number(formatData(item).value)))}
-
-
- ))
- )}
-
- ) : (
- // Staking Records
-
- {this.state.StakingRecords.staking_list_alexander.list.map((item, index) => (
-
-
-
-
- {i18n.t('TAB.Staking')}
- {` ${item.st_type}`}
-
- {moment(item.st_timestamp).format('DD/MM/YYYY HH:mm:ss')}
-
-
- {item.st_type == 'slashed' ? '- ' : '+ '}
- {formatBalance(String(item.st_balance))}
-
-
- ))}
- {this.state.StakingRecords.staking_list_alexander.list &&
- this.state.StakingRecords.staking_list_alexander.list.length > 0 ? (
- this.state.StakingNextPage ? (
-
-
- {i18n.t('TAB.loadMore')}
-
-
- ) : (
-
-
- {i18n.t('TAB.Bottom')}
-
-
- )
- ) : (
-
-
- {i18n.t('Staking.V_no_SR')}
-
-
- )}
-
- )}
-
-
-
- )
- }
-}
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: '#F6F6F6'
- },
- title: {
- padding: ScreenHeight / 50,
- height: ScreenHeight / 9,
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between'
- },
- text_title: {
- fontSize: ScreenHeight / 37,
- fontWeight: 'bold',
- color: 'black'
- },
- image_title: {
- height: ScreenHeight / 35,
- width: ScreenHeight / 35,
- resizeMode: 'contain'
- }
-})
-
-export default ValidatorInfo
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import {
+ StyleSheet,
+ Text,
+ View,
+ TouchableOpacity,
+ ScrollView,
+ Image,
+ StatusBar,
+ Clipboard,
+ SafeAreaView,
+ Alert,
+ InteractionManager
+} from 'react-native'
+import Echarts from 'native-echarts'
+import Identicon from 'polkadot-identicon-react-native'
+import { formatBalance } from '@polkadot/util'
+import moment from 'moment/moment'
+import { observer, inject } from 'mobx-react'
+import Header from '../../../components/Header'
+import { formatData, ScreenWidth, ScreenHeight, axios, doubleClick } from '../../../util/Common'
+import i18n from '../../../locales/i18n'
+import polkadotAPI from '../../../util/polkadotAPI'
+
+@inject('rootStore')
+@observer
+class ValidatorInfo extends Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ address: this.props.navigation.state.params.address,
+ titlebottomAA: 1,
+ nominators: [],
+ nominatorsBalance: [],
+ validatorBalances: 0,
+ StakingNextPage: false,
+ StakingRecords: {},
+ pageNum: 1,
+ inNominators: false,
+ showBtn: false,
+ StakingOption: {
+ title: {
+ text: i18n.t('Staking.StakingOption'),
+ textStyle: {
+ color: '#3E2D32',
+ fontSize: 16
+ },
+ padding: [0, 0, 0, 0]
+ },
+ tooltip: {},
+ legend: {
+ data: ['']
+ },
+ grid: {
+ left: 5
+ },
+ xAxis: {
+ axisLine: {
+ show: false
+ },
+ data: []
+ },
+ yAxis: {
+ axisLine: {
+ show: false
+ },
+ position: 'right'
+ },
+ color: ['#FF5080'],
+ series: [
+ {
+ type: 'line',
+ smooth: true,
+ data: []
+ }
+ ]
+ }
+ }
+ this.back = this.back.bind(this)
+ this.nominate = this.nominate.bind(this)
+ this.Unnominate = this.Unnominate.bind(this)
+ this.copy = this.copy.bind(this)
+ this.Loadmore = this.Loadmore.bind(this)
+ }
+
+ /**
+ * @description 返回|Click back
+ */
+ back() {
+ this.props.navigation.navigate('Tabbed_Navigation')
+ }
+
+ /**
+ * @description 进入Nominate页面|Enter the Nominate page
+ */
+ nominate() {
+ this.props.rootStore.stateStore.tonominate = 1
+ this.props.navigation.navigate('Nominate', { address: this.state.address })
+ }
+
+ /**
+ * @description 进入Unnominate页面|Enter the Unnominate page
+ */
+ Unnominate() {
+ this.props.navigation.navigate('Unnominate')
+ }
+
+ /**
+ * @description 返回
+ */
+ async copy() {
+ Clipboard.setString(this.state.address)
+ Alert.alert('', i18n.t('TAB.CopySuccess'))
+ }
+
+ /**
+ * @description 加载更多|Load for more info
+ */
+ Loadmore() {
+ const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_list_alexander'
+ const params = `{"user_address":"${this.state.address}","pageNum":"${this.state.pageNum}","pageSize":"10"}`
+ axios(REQUEST_URL, params).then(result => {
+ this.setState({
+ StakingNextPage: result.staking_list_alexander.hasNextPage
+ })
+ const _StakingRecords = this.state.StakingRecords
+ result.staking_list_alexander.list.map(item => {
+ _StakingRecords.staking_list_alexander.list.push(item)
+ })
+ this.setState({
+ StakingRecords: _StakingRecords
+ })
+ })
+ }
+
+ componentDidMount() {
+ InteractionManager.runAfterInteractions(() => {
+ ;(async () => {
+ // 获取选中账户的Staking Records
+ // Get Staking Records for the selected account
+ const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_list_alexander'
+ const params = `{"user_address":"${this.state.address}","pageNum":"1","pageSize":"10"}`
+ axios(REQUEST_URL, params)
+ .then(result => {
+ this.setState({
+ StakingNextPage: result.staking_list_alexander.hasNextPage,
+ StakingRecords: result
+ })
+ })
+ .catch()
+ const info = await polkadotAPI.accountInfo(this.state.address)
+ const nominators = formatData(info).stakers.others
+ this.setState({
+ nominators,
+ validatorBalances: formatData(info).stakers.own || formatData(info).stakingLedger.active
+ })
+ let showBtn = false
+ let address = await polkadotAPI.bonded(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ address = String(address)
+ let controller = ''
+ if (!address) {
+ controller = await polkadotAPI.ledger(
+ this.props.rootStore.stateStore.Accounts[this.props.rootStore.stateStore.Account].address
+ )
+ controller = String(controller)
+ if (controller && controller != null && controller != 'null') {
+ showBtn = true
+ this.setState({
+ showBtn: true
+ })
+ }
+ }
+ let tag = false
+ console.log(nominators)
+ if (showBtn) {
+ for (let i = 0; i < nominators.length; i++) {
+ if (formatData(nominators[i]).who == JSON.parse(controller).stash) {
+ tag = true
+ }
+ }
+ }
+ this.setState(
+ {
+ inNominators: tag
+ },
+ () => {
+ console.log(this.state.inNominators)
+ }
+ )
+ })()
+ this.getStakingOption(this.props.navigation.state.params.address)
+ })
+ }
+
+ /**
+ * @description 获取选中账户staking折线图数据|Get the data of staking chart of the selected account
+ * @param {String} address 地址|Address
+ */
+ getStakingOption(address) {
+ ;(async () => {
+ // 获取选中账户staking折线图数据
+ // Get the data of staking chart of the selected account
+ const REQUEST_URL = 'https://api.polkawallet.io:8080/staking_chart_alexander'
+ const params = `{"user_address":"${String(address)}","UTCdate":"${moment(new Date().getTime()).format(
+ 'YYYY-MM-DD HH:mm:ss'
+ )}"}`
+ axios(REQUEST_URL, params)
+ .then(result => {
+ const _StakingOption = {
+ title: {
+ text: i18n.t('Staking.StakingOption'),
+ textStyle: {
+ color: '#3E2D32',
+ fontSize: 16
+ },
+ padding: [0, 0, 0, 0]
+ },
+ tooltip: {},
+ legend: {
+ data: ['']
+ },
+ grid: {
+ left: 5
+ },
+ xAxis: {
+ axisLine: {
+ show: false
+ },
+ data: []
+ },
+ yAxis: {
+ axisLine: {
+ show: false
+ },
+ position: 'right'
+ },
+ color: ['#FF5080'],
+ series: [
+ {
+ type: 'line',
+ smooth: true,
+ data: []
+ }
+ ]
+ }
+ result.map(item => {
+ _StakingOption.xAxis.data.push(`${item.time.substring(5, 7)}/${item.time.substring(8, 10)}`)
+ _StakingOption.series[0].data.push((item.slash_balance / 1000000).toFixed(1))
+ })
+ let max = 0
+ for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
+ if (_StakingOption.series[0].data[i] > max) {
+ max = _StakingOption.series[0].data[i]
+ }
+ }
+ const power =
+ formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).power +
+ formatBalance.getDefaults().decimals
+ const unit = formatBalance.calcSi(String(max), formatBalance.getDefaults().decimals).text
+ for (let i = 0; i < _StakingOption.series[0].data.length; i++) {
+ _StakingOption.series[0].data[i] = (_StakingOption.series[0].data[i] / Number(Math.pow(10, power))).toFixed(
+ 3
+ )
+ }
+ _StakingOption.title.text = `${i18n.t('Staking.stakingOption_new')}( ${unit} )`
+ this.setState({
+ StakingOption: _StakingOption
+ })
+ })
+ .catch()
+ })()
+ }
+
+ render() {
+ return (
+
+
+ {/* 标题栏 | Title bar */}
+
+
+
+
+
+ {/* *********************** 点线图 *********************** */}
+
+
+
+
+
+ {/* 头像 | Identicon */}
+ {
+ doubleClick(this.copy)
+ }}
+ activeOpacity={0.7}
+ >
+
+
+
+ {/* 地址 | Address */}
+
+ {this.state.address}
+
+ {/* 余额 | Balance */}
+
+ {i18n.t('Staking.balance')}
+ {` ${formatBalance(String(Number(this.state.validatorBalances)))}`}
+
+
+ {this.state.showBtn && (
+
+
+
+
+ {this.state.inNominators ? i18n.t('Staking.Unnominate') : i18n.t('Staking.Nominate')}
+
+
+
+ )}
+
+
+ {
+ this.setState({
+ titlebottomAA: 1
+ })
+ }}
+ activeOpacity={0.7}
+ >
+
+
+ {i18n.t('Staking.Nominators')}
+
+
+
+
+ {
+ this.setState({
+ titlebottomAA: 2
+ })
+ }}
+ activeOpacity={0.7}
+ >
+
+
+ {i18n.t('Staking.SlashRecords')}
+
+
+
+
+
+ {this.state.titlebottomAA == 1 ? (
+
+ {// Nominators
+ this.state.nominators.length == 0 ? (
+
+ {i18n.t('Staking.V_no_Nominator')}
+
+ ) : (
+ this.state.nominators.map((item, index) => (
+
+
+
+
+ {formatData(item).who}
+
+
+
+ {formatBalance(String(Number(formatData(item).value)))}
+
+
+ ))
+ )}
+
+ ) : (
+ // Staking Records
+
+ {this.state.StakingRecords.staking_list_alexander &&
+ this.state.StakingRecords.staking_list_alexander.list &&
+ this.state.StakingRecords.staking_list_alexander.list.map((item, index) => (
+
+
+
+
+ {i18n.t('TAB.Staking')}
+ {` ${item.st_type}`}
+
+ {moment(item.st_timestamp).format('DD/MM/YYYY HH:mm:ss')}
+
+
+ {item.st_type == 'slashed' ? '- ' : '+ '}
+ {formatBalance(String(item.st_balance))}
+
+
+ ))}
+ {this.state.StakingRecords.staking_list_alexander.list &&
+ this.state.StakingRecords.staking_list_alexander.list.length > 0 ? (
+ this.state.StakingNextPage ? (
+
+
+ {i18n.t('TAB.loadMore')}
+
+
+ ) : (
+
+
+ {i18n.t('TAB.Bottom')}
+
+
+ )
+ ) : (
+
+
+ {i18n.t('Staking.V_no_SR')}
+
+
+ )}
+
+ )}
+
+
+
+ )
+ }
+}
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: '#F6F6F6'
+ },
+ title: {
+ padding: ScreenHeight / 50,
+ height: ScreenHeight / 9,
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'space-between'
+ },
+ text_title: {
+ fontSize: ScreenHeight / 37,
+ fontWeight: 'bold',
+ color: 'black'
+ },
+ image_title: {
+ height: ScreenHeight / 35,
+ width: ScreenHeight / 35,
+ resizeMode: 'contain'
+ }
+})
+
+export default ValidatorInfo
diff --git a/src/page/TabbedNavigation.js b/src/page/TabbedNavigation.js
index d8841325..fea75923 100755
--- a/src/page/TabbedNavigation.js
+++ b/src/page/TabbedNavigation.js
@@ -1,156 +1,154 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import React, { Component } from 'react'
-import { Text } from 'react-native'
-import { createBottomTabNavigator } from 'react-navigation'
-import Assets from './Assets/Assets'
-import Staking from './Staking/Staking'
-import Democracy from './Democracy/Democracy'
-import Profile from './Profile/Profile'
-import Diceng from '../components/bottom'
-import i18n from '../locales/i18n'
-
-const TabRouteConfigs = {
- Assets: {
- screen: Assets,
- navigationOptions: ({ navigation }) => ({
- tabBarLabel: ({ tintColor }) => (
-
- {i18n.t('TAB.Assets')}
-
- ),
- tabBarIcon: ({ b, tintColor }) => (
-
- ),
- tabBarOnPress: () => {
- route(navigation, 'Assets')
- }
- })
- },
- Staking: {
- screen: Staking,
- navigationOptions: ({ navigation }) => ({
- tabBarLabel: ({ tintColor }) => (
-
- {i18n.t('TAB.Staking')}
-
- ),
- tabBarIcon: ({ b, tintColor }) => (
-
- ),
- tabBarOnPress: () => {
- route(navigation, 'Staking')
- }
- })
- },
- Democracy: {
- screen: Democracy,
- navigationOptions: ({ navigation }) => ({
- tabBarLabel: ({ tintColor }) => (
-
- {i18n.t('TAB.Democracy')}
-
- ),
- tabBarIcon: ({ b, tintColor }) => (
-
- ),
- tabBarOnPress: () => {
- route(navigation, 'Democracy')
- }
- })
- },
- Profile: {
- screen: Profile,
- navigationOptions: ({ navigation }) => ({
- tabBarLabel: ({ tintColor }) => (
-
- {i18n.t('TAB.Profile')}
-
- ),
- tabBarIcon: ({ b, tintColor }) => (
-
- ),
- tabBarOnPress: () => {
- route(navigation, 'Profile')
- }
- })
- }
-}
-const TabNavigatorConfigs = {
- tabBarOptions: {
- activeTintColor: '#E64874',
- labelStyle: {
- fontSize: 10,
- justifyContent: 'center',
- alignItems: 'center'
- },
- tabStyle: {
- fontSize: 10,
- justifyContent: 'center',
- alignItems: 'center'
- }
- },
- initialRouteName: 'Assets',
- tabBarPosition: 'bottom',
- lazy: false
-}
-const Tab = createBottomTabNavigator(TabRouteConfigs, TabNavigatorConfigs)
-module.exports = Tab
-export default class Navigation extends Component {
- static navigationOptions = {
- header: null
- }
-
- constructor(props) {
- super(props)
- }
-
- render() {
- return
- }
-}
-const route = (navigation, path) => {
- console.log(navigation)
- console.log(navigation.navigate)
- if (!navigation.isFocused() && !global.LoadingTip) {
- navigation.navigate(path)
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import React, { Component } from 'react'
+import { Text } from 'react-native'
+import { createBottomTabNavigator } from 'react-navigation'
+import Assets from './Assets/Assets'
+import Staking from './Staking/Staking'
+import Democracy from './Democracy/Democracy'
+import Profile from './Profile/Profile'
+import Diceng from '../components/bottom'
+import i18n from '../locales/i18n'
+
+const TabRouteConfigs = {
+ Assets: {
+ screen: Assets,
+ navigationOptions: ({ navigation }) => ({
+ tabBarLabel: ({ tintColor }) => (
+
+ {i18n.t('TAB.Assets')}
+
+ ),
+ tabBarIcon: ({ b, tintColor }) => (
+
+ ),
+ tabBarOnPress: () => {
+ route(navigation, 'Assets')
+ }
+ })
+ },
+ Staking: {
+ screen: Staking,
+ navigationOptions: ({ navigation }) => ({
+ tabBarLabel: ({ tintColor }) => (
+
+ {i18n.t('TAB.Staking')}
+
+ ),
+ tabBarIcon: ({ b, tintColor }) => (
+
+ ),
+ tabBarOnPress: () => {
+ route(navigation, 'Staking')
+ }
+ })
+ },
+ Democracy: {
+ screen: Democracy,
+ navigationOptions: ({ navigation }) => ({
+ tabBarLabel: ({ tintColor }) => (
+
+ {i18n.t('TAB.Democracy')}
+
+ ),
+ tabBarIcon: ({ b, tintColor }) => (
+
+ ),
+ tabBarOnPress: () => {
+ route(navigation, 'Democracy')
+ }
+ })
+ },
+ Profile: {
+ screen: Profile,
+ navigationOptions: ({ navigation }) => ({
+ tabBarLabel: ({ tintColor }) => (
+
+ {i18n.t('TAB.Profile')}
+
+ ),
+ tabBarIcon: ({ b, tintColor }) => (
+
+ ),
+ tabBarOnPress: () => {
+ route(navigation, 'Profile')
+ }
+ })
+ }
+}
+const TabNavigatorConfigs = {
+ tabBarOptions: {
+ activeTintColor: '#E64874',
+ labelStyle: {
+ fontSize: 10,
+ justifyContent: 'center',
+ alignItems: 'center'
+ },
+ tabStyle: {
+ fontSize: 10,
+ justifyContent: 'center',
+ alignItems: 'center'
+ }
+ },
+ initialRouteName: 'Assets',
+ tabBarPosition: 'bottom',
+ lazy: false
+}
+const Tab = createBottomTabNavigator(TabRouteConfigs, TabNavigatorConfigs)
+module.exports = Tab
+export default class Navigation extends Component {
+ static navigationOptions = {
+ header: null
+ }
+
+ constructor(props) {
+ super(props)
+ }
+
+ render() {
+ return
+ }
+}
+const route = (navigation, path) => {
+ if (!navigation.isFocused() && !global.LoadingTip) {
+ navigation.navigate(path)
+ }
+}
diff --git a/src/util/Common.js b/src/util/Common.js
index c0c9d62c..1c0b1c0d 100755
--- a/src/util/Common.js
+++ b/src/util/Common.js
@@ -1,184 +1,224 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-20 21:01:02
- */
-import SInfo from 'react-native-sensitive-info'
-import Keyring from '@polkadot/keyring'
-import { Dimensions, Alert } from 'react-native'
-import i18n from '../locales/i18n'
-// 返回页面宽度
-// Get page width
-export const ScreenWidth = Dimensions.get('window').width
-// 返回页面高度
-// Get page height
-export const ScreenHeight = Dimensions.get('window').height
-
-// 根据单位名称获取值
-// Gets the value based on the unit name
-export function getUnit(type) {
- let unit = 1
- type = String(type)
- switch (type) {
- case 'femto':
- unit = '1'
- break
- case 'pico':
- unit = '1000'
- break
- case 'nano':
- unit = '1000000'
- break
- case 'micro':
- unit = '1000000000'
- break
- case 'milli':
- unit = '1000000000000'
- break
- case 'DOT':
- unit = '1000000000000000'
- break
- case 'Kilo':
- unit = '1000000000000000000'
- break
- case 'Mega':
- unit = '1000000000000000000000'
- break
- case 'Giga':
- unit = '1000000000000000000000000'
- break
- case 'Tera':
- unit = '1000000000000000000000000000'
- break
- case 'Peta':
- unit = '1000000000000000000000000000000'
- break
- case 'Exa':
- unit = '1000000000000000000000000000000000'
- break
- case 'Zeta':
- unit = '1000000000000000000000000000000000000'
- break
- default:
- // Yotta
- unit = '1000000000000000000000000000000000000000'
- }
- return unit
-}
-/**
- * 校验密码 方法整合 | Verify password, method integration
- * @param {Object} params 传入的对象 | Incoming object
- * @param {String} params.address 地址 | Address
- * @param {String} params.password 密码 | Password
- * @param {Function} params.success 成功回调方法 | Success callback method
- * @param {Function} params.error 密码错误的回调 | Password error callback method
- */
-export function checkPwd(params) {
- const keyring = new Keyring()
- SInfo.getItem(params.address, {
- sharedPreferencesName: 'Polkawallet',
- keychainService: 'PolkawalletKey'
- }).then(result => {
- const loadPair = keyring.addFromJson(JSON.parse(result))
- try {
- loadPair.decodePkcs8(params.password)
- } catch (error) {
- params.error && params.error()
- Alert.alert(
- '',
- i18n.t('TAB.PasswordMistake'),
- [
- {
- text: 'OK',
- onPress: () => {}
- }
- ],
- { cancelable: false }
- )
- }
- !loadPair.isLocked() && (params.success && params.success(loadPair, SInfo))
- })
-}
-
-// 格式化api返回的对象
-// Format the object returned by the API
-export function formatData(data) {
- if (data) {
- return JSON.parse(JSON.stringify(data))
- }
-}
-export function axios(url, params, type = 'POST', noJson = false) {
- const map = {
- method: type
- }
- const privateHeaders = {
- 'Content-Type': 'application/json'
- }
- map.headers = privateHeaders
- map.follow = 20
- map.timeout = 0
- map.body = params
- if (noJson) {
- return new Promise((resolve, reject) => {
- fetch(url, map)
- .then(responseData => {
- resolve(responseData)
- })
- .catch(error => {
- reject(error)
- })
- })
- }
- return new Promise((resolve, reject) => {
- fetch(url, map)
- .then(response => response.json())
- .then(responseData => {
- if (responseData) {
- resolve(responseData)
- } else {
- reject(console.log('responseData is null'))
- }
- })
- .catch(error => {
- reject(error)
- })
- })
-}
-export function accountId(address, networkType = 'substrate') {
- if (typeof address !== 'string' || address.length === 0) {
- return ''
- } else {
- return `${networkType}:${address}`
- }
-}
-export function ScannerType(data) {
- if (typeof data !== 'string' || !data) {
- return ''
- } else {
- let type = ''
- let QRData = ''
- try {
- if (data.indexOf('substrate:') > -1) {
- type = 'substrate'
- QRData = data.split('substrate:')[1]
- } else {
- type = ''
- QRData = data
- }
- } catch (e) {
- type = ''
- QRData = data
- }
- return {
- type: type,
- data: QRData
- }
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import SInfo from 'react-native-sensitive-info'
+import Keyring from '@polkadot/keyring'
+import { Dimensions, Alert } from 'react-native'
+import i18n from '../locales/i18n'
+// 返回页面宽度
+// Get page width
+export const ScreenWidth = Dimensions.get('window').width
+// 返回页面高度
+// Get page height
+export const ScreenHeight = Dimensions.get('window').height
+
+/**
+ * @description 根据单位名称获取值|Gets the value based on the unit name
+ * @param {String} type 单位
+ */
+export function getUnit(type) {
+ let unit = 1
+ type = String(type)
+ switch (type) {
+ case 'femto':
+ unit = '1'
+ break
+ case 'pico':
+ unit = '1000'
+ break
+ case 'nano':
+ unit = '1000000'
+ break
+ case 'micro':
+ unit = '1000000000'
+ break
+ case 'milli':
+ unit = '1000000000000'
+ break
+ case 'DOT':
+ unit = '1000000000000000'
+ break
+ case 'Kilo':
+ unit = '1000000000000000000'
+ break
+ case 'Mega':
+ unit = '1000000000000000000000'
+ break
+ case 'Giga':
+ unit = '1000000000000000000000000'
+ break
+ case 'Tera':
+ unit = '1000000000000000000000000000'
+ break
+ case 'Peta':
+ unit = '1000000000000000000000000000000'
+ break
+ case 'Exa':
+ unit = '1000000000000000000000000000000000'
+ break
+ case 'Zeta':
+ unit = '1000000000000000000000000000000000000'
+ break
+ default:
+ // Yotta
+ unit = '1000000000000000000000000000000000000000'
+ }
+ return unit
+}
+/**
+ * @description 校验密码 方法整合 | Verify password, method integration
+ * @param {Object} params 传入的对象 | Incoming object
+ * @param {String} params.address 地址 | Address
+ * @param {String} params.password 密码 | Password
+ * @param {Function} params.success 成功回调方法 | Success callback method
+ * @param {Function} params.error 密码错误的回调 | Password error callback method
+ */
+export function checkPwd(params) {
+ const keyring = new Keyring()
+ SInfo.getItem(params.address, {
+ sharedPreferencesName: 'Polkawallet',
+ keychainService: 'PolkawalletKey'
+ }).then(result => {
+ const loadPair = keyring.addFromJson(JSON.parse(result))
+ try {
+ loadPair.decodePkcs8(params.password)
+ } catch (error) {
+ Alert.alert(
+ '',
+ i18n.t('TAB.PasswordMistake'),
+ [
+ {
+ text: 'OK',
+ onPress: () => {
+ params.error && params.error()
+ }
+ }
+ ],
+ { cancelable: false }
+ )
+ }
+ !loadPair.isLocked() && (params.success && params.success(loadPair, SInfo))
+ })
+}
+
+/**
+ * @description 格式化api返回的对象 | Format the object returned by the API
+ * @param {Object} data 格式化的对象 | Formatting object
+ * @returns 格式化完的对象 | Formatted object
+ */
+export function formatData(data) {
+ if (data) {
+ return JSON.parse(JSON.stringify(data))
+ }
+}
+/**
+ * @description 请求接口 方法整合 | Request interface method integration
+ * @param {String} url 请求的地址 | Requested url
+ * @param {String} params 请求的参数 | Requested parameters
+ * @param {String} type 请求的方式 默认 post | The mode of request defaults to post
+ * @param {Boolean} noJson 是否需要对数据进行处理 默认false(需要) | Need to process the data, default false
+ */
+export function axios(url, params, type = 'POST', noJson = false) {
+ const map = {
+ method: type
+ }
+ const privateHeaders = {
+ 'Content-Type': 'application/json'
+ }
+ map.headers = privateHeaders
+ map.follow = 20
+ map.timeout = 0
+ map.body = params
+ if (noJson) {
+ return new Promise((resolve, reject) => {
+ fetch(url, map)
+ .then(responseData => {
+ resolve(responseData)
+ })
+ .catch(error => {
+ reject(error)
+ })
+ })
+ }
+ return new Promise((resolve, reject) => {
+ fetch(url, map)
+ .then(response => response.json())
+ .then(responseData => {
+ if (responseData) {
+ resolve(responseData)
+ } else {
+ reject(console.log('responseData is null'))
+ }
+ })
+ .catch(error => {
+ reject(error)
+ })
+ })
+}
+/**
+ * @description 增加网络类型 | Add network type
+ * @param {String} address 地址 | Address
+ * @param {String} networkType 网络类型 | Network type
+ */
+export function accountId(address, networkType = 'substrate') {
+ if (typeof address !== 'string' || address.length === 0) {
+ return ''
+ } else {
+ return `${networkType}:${address}`
+ }
+}
+/**
+ * @description 根据扫描结果判断 网络类型和地址 | Determine the network type and address based on the scan results
+ * @param {String} data 识别到的JSONString | JSONString recognized
+ */
+export function ScannerType(data) {
+ if (typeof data !== 'string' || !data) {
+ return ''
+ } else {
+ let type = ''
+ let QRData = ''
+ try {
+ if (data.indexOf('substrate:') > -1) {
+ type = 'substrate'
+ QRData = data.split('substrate:')[1]
+ } else {
+ type = ''
+ QRData = data
+ }
+ } catch (e) {
+ type = ''
+ QRData = data
+ }
+ return {
+ type: type,
+ data: QRData
+ }
+ }
+}
+let isCalled = false
+let timer = null
+/**
+ * @description 连续点击判断 | Keep clicking to judge
+ * @param yourFunction 点击事件 | Click event
+ * @param interval 时间间隔,可省略,默认2000毫秒 | Time interval, can be omitted, default 2000 ms
+ *
+ */
+export function doubleClick(clickFun, interval = 2000) {
+ if (!isCalled) {
+ isCalled = true
+ clearTimeout(timer)
+ timer = setTimeout(() => {
+ isCalled = false
+ }, interval)
+ return clickFun()
+ }
+}
diff --git a/src/util/DataRepository.js b/src/util/DataRepository.js
index db7574ca..39fff66c 100755
--- a/src/util/DataRepository.js
+++ b/src/util/DataRepository.js
@@ -1,98 +1,96 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-import { AsyncStorage } from 'react-native'
-
-/**
- * 数据持久化类 | Data persistence class
- */
-export default class DataRepository {
- /**
- * 保存本地数据
- * @param key key
- * @param items value
- * @param callback 回调函数
- */
- saveLocalRepository(key, items, callback) {
- if (!items || !key) return
-
- AsyncStorage.setItem(key, JSON.stringify(items), callback)
- }
-
- /**
- * 获取本地的数据
- * @param key
- * @returns {Promise}
- */
- fetchLocalRepository(key) {
- return new Promise((resolve, reject) => {
- AsyncStorage.getItem(key, (error, result) => {
- if (!error) {
- try {
- resolve(JSON.parse(result))
- } catch (e) {
- reject(e)
- console.log(e)
- }
- } else {
- reject(error)
- console.log(error)
- }
- })
- })
- }
-
- /**
- * 移除本地存的key
- * @param key
- * @returns {*}
- */
- removeLocalRepository(key, callback) {
- if (!key) return
-
- AsyncStorage.removeItem(key, callback)
- }
-
- /**
- * 移除本地存的keys
- * @param keys
- * @returns {*}
- */
- removeMultiLocalRepository(keys, callback) {
- if (!keys) return
-
- AsyncStorage.multiRemove(keys, callback)
- }
-
- /**
- * 获取网络的数据
- * @param key
- * @returns {Promise}
- */
- fetchNetRepository(key) {
- return new Promise((resolve, reject) => {
- fetch(key)
- .then(response => response.json())
- .then(responseData => {
- if (responseData) {
- this.saveRepository(key, responseData)
- resolve(responseData)
- } else {
- reject(new Error('responseData is null'))
- }
- })
- .catch(error => {
- reject(error)
- })
- })
- }
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import { AsyncStorage } from 'react-native'
+
+/**
+ * @description 数据持久化类 | Data persistence class
+ */
+export default class DataRepository {
+ /**
+ * @description 保存本地数据 | Save local data
+ * @param key key
+ * @param items value
+ * @param callback 回调函数 | callback
+ */
+ saveLocalRepository(key, items, callback) {
+ if (!items || !key) return
+
+ AsyncStorage.setItem(key, JSON.stringify(items), callback)
+ }
+
+ /**
+ * @description 获取本地的数据 | Get local data
+ * @param key
+ * @returns {Promise}
+ */
+ fetchLocalRepository(key) {
+ return new Promise((resolve, reject) => {
+ AsyncStorage.getItem(key, (error, result) => {
+ if (!error) {
+ try {
+ resolve(JSON.parse(result))
+ } catch (e) {
+ reject(e)
+ }
+ } else {
+ reject(error)
+ }
+ })
+ })
+ }
+
+ /**
+ * @description 移除本地存的key | Removes locally stored key
+ * @param key
+ * @returns {*}
+ */
+ removeLocalRepository(key, callback) {
+ if (!key) return
+
+ AsyncStorage.removeItem(key, callback)
+ }
+
+ /**
+ * @description 移除本地存的keys | Removes locally stored keys
+ * @param keys
+ * @returns {*}
+ */
+ removeMultiLocalRepository(keys, callback) {
+ if (!keys) return
+
+ AsyncStorage.multiRemove(keys, callback)
+ }
+
+ /**
+ * @description 获取网络的数据 | Get network data
+ * @param key
+ * @returns {Promise}
+ */
+ fetchNetRepository(key) {
+ return new Promise((resolve, reject) => {
+ fetch(key)
+ .then(response => response.json())
+ .then(responseData => {
+ if (responseData) {
+ this.saveRepository(key, responseData)
+ resolve(responseData)
+ } else {
+ reject(new Error('responseData is null'))
+ }
+ })
+ .catch(error => {
+ reject(error)
+ })
+ })
+ }
+}
diff --git a/src/util/error_guard.js b/src/util/error_guard.js
index c93ec988..88cf0658 100755
--- a/src/util/error_guard.js
+++ b/src/util/error_guard.js
@@ -1,36 +1,36 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-18 21:08:00
- */
-const noop = () => {}
-
-export const setJSExceptionHandler = (customHandler = noop, allowedInDevMode = false) => {
- if (typeof allowedInDevMode !== 'boolean' || typeof customHandler !== 'function') {
- return
- }
- const allowed = allowedInDevMode ? true : !__DEV__
- if (allowed) {
- // !!! 关键代码
- // 设置错误处理函数
- // Pivotal code: Set up error handlers
- global.ErrorUtils.setGlobalHandler(customHandler)
- // 改写 console.error,保证报错能被 ErrorUtils 捕获并调用错误处理函数处理
- // Rewrite console.error to ensure that the error is caught by ErrorUtils and handled by the error handler function
- console.error = (message, error) => global.ErrorUtils.reportError(error)
- }
-}
-
-export const getJSExceptionHandler = () => global.ErrorUtils.getGlobalHandler()
-
-export default {
- setJSExceptionHandler,
- getJSExceptionHandler
-}
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+const noop = () => {}
+
+export const setJSExceptionHandler = (customHandler = noop, allowedInDevMode = false) => {
+ if (typeof allowedInDevMode !== 'boolean' || typeof customHandler !== 'function') {
+ return
+ }
+ const allowed = allowedInDevMode ? true : !__DEV__
+ if (allowed) {
+ // !!! 关键代码
+ // 设置错误处理函数
+ // Pivotal code: Set up error handlers
+ global.ErrorUtils.setGlobalHandler(customHandler)
+ // 改写 console.error,保证报错能被 ErrorUtils 捕获并调用错误处理函数处理
+ // Rewrite console.error to ensure that the error is caught by ErrorUtils and handled by the error handler function
+ console.error = (message, error) => global.ErrorUtils.reportError(error)
+ }
+}
+
+export const getJSExceptionHandler = () => global.ErrorUtils.getGlobalHandler()
+
+export default {
+ setJSExceptionHandler,
+ getJSExceptionHandler
+}
diff --git a/src/util/polkadotAPI.js b/src/util/polkadotAPI.js
index 37313fd7..4c9a6745 100755
--- a/src/util/polkadotAPI.js
+++ b/src/util/polkadotAPI.js
@@ -1,528 +1,546 @@
-/*
- * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
- * This file is part of Polkawallet.
-
- It under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License.
- You should have received a copy of the GNU General Public License
- along with Polkawallet. If not, see .
-
- * @Autor: POLKAWALLET LIMITED
- * @Date: 2019-06-20 20:42:10
- */
-import Api from '@polkadot/api/promise'
-import WsProvider from '@polkadot/rpc-provider/ws'
-import AppState from '../mobx/mobx'
-
-function judgeObj(obj) {
- let attr
- for (attr in obj) {
- return false
- }
- return true
-}
-const getAppApi = async () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- if (judgeObj(AppState.stateStore.API)) {
- const provider = new WsProvider(AppState.stateStore.ENDPOINT)
- const api = await Api.create(provider)
- AppState.stateStore.API = api
- resolve(api)
- } else {
- resolve(AppState.stateStore.API)
- }
- })()
- } catch (error) {
- reject(error)
- }
- })
-const polkadotAPI = {
- timestampNow: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.query.timestamp.now(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.timestamp.now()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- freeBalance: (_address, cb) => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.query.balances.freeBalance(_address, cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.balances.freeBalance(_address)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- properties: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.rpc.system.properties()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- fees: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.balances.fees()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- accountNonce: address =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.system.accountNonce(address)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- transfer: (_address, _value) =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = api.tx.balances.transfer(_address, _value)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- publicPropCount: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.query.democracy.publicPropCount(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.democracy.publicPropCount()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- referendumCount: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.query.democracy.referendumCount(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.democracy.referendumCount()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- publicProps: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.query.democracy.publicProps(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.democracy.publicProps()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- referendums: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.derive.democracy.referendums(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.democracy.referendums()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- launchPeriod: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.democracy.launchPeriod()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- bestNumber: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.derive.chain.bestNumber(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.chain.bestNumber()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- depositOf: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.democracy.depositOf()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- vote: (i, tag) =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.tx.democracy.vote(i, tag)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- bondExtra: val =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.tx.staking.bondExtra(val)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- bond: (controller, val, payee) =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.tx.staking.bond(controller, val, payee)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- accountInfo: account =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.staking.info(account)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- nominators: stash =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.staking.nominators(stash)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- nominate: target =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.tx.staking.nominate(target)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- setKey: key =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.tx.session.setKey(key)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- validate: preferences =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.tx.staking.validate(preferences)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- unbond: val =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.tx.staking.unbond(val)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- chill: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.tx.staking.chill()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
-
- validatorCount: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.staking.validatorCount()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- sessionLength: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.session.sessionLength()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- eraLength: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.session.eraLength()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- sessionProgress: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.derive.session.sessionProgress(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.session.sessionProgress()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- eraProgress: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.derive.session.eraProgress(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.session.eraProgress()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- validators: () =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.session.validators()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- controllers: cb => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.derive.staking.controllers(cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.staking.controllers()
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- },
- bonded: address =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.staking.bonded(address)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- ledger: address =>
- new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.query.staking.ledger(address)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- }),
- referendumVotesFor: (i, cb) => {
- if (cb) {
- ;(async () => {
- const api = await getAppApi()
- await api.derive.democracy.referendumVotesFor(i, cb)
- })()
- } else {
- return new Promise(function(resolve, reject) {
- try {
- ;(async () => {
- const api = await getAppApi()
- const _data = await api.derive.democracy.referendumVotesFor(i)
- resolve(_data)
- })()
- } catch (error) {
- reject(error)
- }
- })
- }
- }
-}
-export default polkadotAPI
+/*
+ * @Description: COPYRIGHT © 2018 POLKAWALLET (HK) LIMITED
+ * This file is part of Polkawallet.
+
+ It under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+ You should have received a copy of the GNU General Public License
+ along with Polkawallet. If not, see .
+
+ * @Autor: POLKAWALLET LIMITED
+ * @Date: 2019-06-18 21:08:00
+ */
+import Api from '@polkadot/api/promise'
+import WsProvider from '@polkadot/rpc-provider/ws'
+import AppState from '../mobx/mobx'
+
+/**
+ * @description 判断是否为空对象 | Empty object judgment
+ * @param {Object} obj 对象 | Object
+ * @returns {Boolean} true 空对象 false 非空对象 | True: empty object, false: non-empty object
+ */
+function judgeObj(obj) {
+ let attr
+ for (attr in obj) {
+ return false
+ }
+ return true
+}
+const getAppApi = async () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ if (judgeObj(AppState.stateStore.API)) {
+ const provider = new WsProvider(AppState.stateStore.ENDPOINT)
+ const api = await Api.create(provider)
+ AppState.stateStore.API = api
+ resolve(api)
+ } else {
+ resolve(AppState.stateStore.API)
+ }
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+const polkadotAPI = {
+ timestampNow: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.query.timestamp.now(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.timestamp.now()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ freeBalance: (_address, cb) => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.query.balances.freeBalance(_address, cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.balances.freeBalance(_address)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ properties: () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.rpc.system.properties()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ fees: () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.balances.fees()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ accountNonce: address =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.system.accountNonce(address)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ transfer: (_address, _value) =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = api.tx.balances.transfer(_address, _value)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ publicPropCount: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.query.democracy.publicPropCount(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.democracy.publicPropCount()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ referendumCount: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.query.democracy.referendumCount(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.democracy.referendumCount()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ publicProps: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.query.democracy.publicProps(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.democracy.publicProps()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ referendums: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.derive.democracy.referendums(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.democracy.referendums()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ launchPeriod: () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.democracy.launchPeriod()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ bestNumber: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.derive.chain.bestNumber(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.chain.bestNumber()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ depositOf: index =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.democracy.depositOf(index)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ vote: (i, tag) =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.tx.democracy.vote(i, tag)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ bondExtra: val =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.tx.staking.bondExtra(val)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ bond: (controller, val, payee) =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.tx.staking.bond(controller, val, payee)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ accountInfo: account =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.staking.info(account)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ nominators: stash =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.staking.nominators(stash)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ nominate: target =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.tx.staking.nominate(target)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ setKey: key =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.tx.session.setKey(key)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ validate: preferences =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.tx.staking.validate(preferences)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ unbond: val =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.tx.staking.unbond(val)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ chill: () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.tx.staking.chill()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+
+ validatorCount: () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.staking.validatorCount()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ sessionLength: () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.session.sessionLength()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ eraLength: () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.session.eraLength()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ sessionProgress: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.derive.session.sessionProgress(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.session.sessionProgress()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ eraProgress: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.derive.session.eraProgress(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.session.eraProgress()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ validators: () =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.session.validators()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ controllers: cb => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.derive.staking.controllers(cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.staking.controllers()
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ },
+ bonded: address =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.staking.bonded(address)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ ledger: address =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.staking.ledger(address)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+
+ blockHash: value =>
+ new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.query.system.blockHash(value)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ }),
+ referendumVotesFor: (i, cb) => {
+ if (cb) {
+ ;(async () => {
+ const api = await getAppApi()
+ await api.derive.democracy.referendumVotesFor(i, cb)
+ })()
+ } else {
+ return new Promise(function(resolve, reject) {
+ try {
+ ;(async () => {
+ const api = await getAppApi()
+ const _data = await api.derive.democracy.referendumVotesFor(i)
+ resolve(_data)
+ })()
+ } catch (error) {
+ reject(error)
+ }
+ })
+ }
+ }
+}
+export default polkadotAPI